如何在struts中将ID传递给action.java?
How to pass ID to action.java in struts?
我在 jsp 文件中有这段代码:
<%
int j = 1;
while (variableTypesIterator.hasNext()) {
VariableType c = new VariableType();
c = variableTypesIterator.next();
if (variableTypeId != null && c.getVariableTypeId().equals(variableTypeId)) {
%>
<br/>
<li><label><%=c.getVariableTypeId()%>
</label> <html:link action="/policyBasicInfo.do?method=selectedVariableType"
style="text-decoration: none;"><%=c.getVariableTypeName()%>
</html:link></li>
<%
} else {
%>
<br/>
<li><html:link action="/policyBasicInfo.do?method=selectedVariableType"
style="text-decoration: none;"><%=c.getVariableTypeName()%>
</html:link></li>
<input type="VtId" id="VtId" name="VtId" value="<%=c.getVariableTypeId()%>"/>
<%
}
j++;
}
%>
<%
}
%>
如何将 ID(输入文本值)传递给 struts 中的操作文件?
当用户点击link?
更简单的方法是
<a href="/policyBasicInfo.do?method=selectedVariableType&variableTypeId=<%=c.getVariableTypeId()%>"><%=c.getVariableTypeName()%></a>
我在 jsp 文件中有这段代码:
<%
int j = 1;
while (variableTypesIterator.hasNext()) {
VariableType c = new VariableType();
c = variableTypesIterator.next();
if (variableTypeId != null && c.getVariableTypeId().equals(variableTypeId)) {
%>
<br/>
<li><label><%=c.getVariableTypeId()%>
</label> <html:link action="/policyBasicInfo.do?method=selectedVariableType"
style="text-decoration: none;"><%=c.getVariableTypeName()%>
</html:link></li>
<%
} else {
%>
<br/>
<li><html:link action="/policyBasicInfo.do?method=selectedVariableType"
style="text-decoration: none;"><%=c.getVariableTypeName()%>
</html:link></li>
<input type="VtId" id="VtId" name="VtId" value="<%=c.getVariableTypeId()%>"/>
<%
}
j++;
}
%>
<%
}
%>
如何将 ID(输入文本值)传递给 struts 中的操作文件? 当用户点击link?
更简单的方法是
<a href="/policyBasicInfo.do?method=selectedVariableType&variableTypeId=<%=c.getVariableTypeId()%>"><%=c.getVariableTypeName()%></a>