Request parameter in jsp page
Im setting my parameter in my jsp like so -
<s:url id="ope开发者_运维百科n" action="viewEvent">
<s:param name="eventName" value="eventName" />
</s:url> <sj:a href="%{open}" targets="eventSearchResultsDiv">Open</sj:a>
How can I access this parameter in my jsp page. This does'nt seem to be working -
<s:property value="eventName" />
Although this works - <%= request.getParameter("eventName") %>
Thanks
The documentation says :
Assuming there's a request parameter myParameter (e.g. http://host/myApp/myAction.action?myParameter=one).
<s:property value="%{#parameters.myParameter}" />
There are some implicit objects in JSP pages that provide access to this sort of information. The one you are looking for is param. If you were writing jstl with c:out for example you could do:
<c:out value="${param.eventName}"/>
Or in your example:
<s:url id="open" action="viewEvent">
<s:param name="eventname" value="${param.eventName}"/>
</s:url>
精彩评论