i'm trying generate link each string in list of strings. link call action , pass in parameter (a getstudentbyid action passing in studentid). i've tried couple of ways work searching on interwebs, however, have not had luck. recent try results in each link having url of "www.com" have no clue comes from. below couple of files consideration in trying me figure out what's going wrong.
winneracknowledgement.jsp
<!doctype html> <%@ taglib prefix="s" uri="/struts-tags" %> <html> <head> <link rel="stylesheet" href="${pagecontext.request.contextpath}/js/jquery/jquery-ui-1.11.4/jquery-ui.css" type="text/css" media="all"/> <link rel="stylesheet" href="${pagecontext.request.contextpath}/js/jquery/jquery-ui-1.11.4/jquery-ui.theme.css" type="text/css" media="all"/> <link rel="stylesheet" href="${pagecontext.request.contextpath}/css/bootstrap/bootstrap-datepicker.css" type="text/css" /> <link rel="stylesheet" href="${pagecontext.request.contextpath}/css/survey_bh.css" type="text/css" /> <link rel="stylesheet" href="${pagecontext.request.contextpath}/css/style_bh.css" type="text/css" /> </head> <body> <a href='index.jsp'>home</a> <p>survey saved!</p> <p>congratulations! you're winner of raffle , have won 2 movie tickets.</p> <div> <s:set var="mean" value="db.mean"/> <s:set var="standarddeviation" value="db.standarddeviation"/> <p><span><strong>mean:</strong></span> <span><s:number name="%{mean}" type="number" /></span></p> <p><span><strong>standard deviation:</strong></span> <span><s:number name="%{standarddeviation}" type="number" /></span></p> </div> <div> <p>students:</p> <ul> <s:iterator value="studentids" status="status"> <s:url action="getstudentbyid" includeparams="get" var="url"> <s:param name="studentid"><s:property/></s:param> </s:url> <li> <s:a href="%{url}"><s:property/></s:a> </li> </s:iterator> </ul> </div> </body> </html>
struts.xml
<!--?xml version="1.0" encoding="utf-8" ?--> <!doctype struts public "-//apache software foundation//dtd struts configuration 2.0//en" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.enable.dynamicmethodinvocation" value="false"></constant> <constant name="struts.devmode" value="false"></constant> <constant name="struts.custom.i18n.resources" value="applicationresources"></constant> <package name="default" extends="struts-default" namespace="/"> <action name="getstudentbyid" class="com.action.surveyaction" method="getstudentbyid"> <result name="success">student.jsp</result> <result name="error">nosuchstudent.jsp</result> </action> <action name="savesurvey" class="com.action.surveyaction" method="savesurvey"> <result name="simple">simpleacknowledgement.jsp</result> <result name="winner">winneracknowledgement.jsp</result> <result name="error">error.jsp</result> </action> </package> </struts>
instead of:
<s:iterator value="studentids" status="status"> <s:url action="getstudentbyid" includeparams="get" var="url"> <s:param name="studentid"><s:property/></s:param> </s:url> <li> <s:a href="%{url}"><s:property/></s:a> </li> </s:iterator>
i tried , worked:
<s:iterator value="studentids" status="status"> <s:url action="getstudentbyid" includeparams="get" var="url"> <s:param name="studentid"><s:property/></s:param> </s:url> <li> <s:a href="%{#url}"><s:property/></s:a> </li> </s:iterator>
the difference being %{url} vs %{#url}