I'm looking for something like that in Struts 2 :

<s:textfield name="name" value="%{#request.getRemoteUser()}" 
                              label="Evaluateur"  required="true" />

this not work and I'm testing

<s:textfield name="name" value="<%=request.getRemoteUser()%>"
                              label="Evaluateur"  required="true" />
有帮助吗?

解决方案

You can get a HttpServletRequest object in JSP from the action context with com.opensymphony.xwork2.dispatcher.HttpServletRequest key or by using static property of StrutsStatics interface.

<s:textfield value="%{#context[@org.apache.struts2.StrutsStatics@HTTP_REQUEST].getRemoteUser()}"/>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top