Question

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" />
Était-ce utile?

La solution

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()}"/>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top