我在我的 JSP < s: include value="test.html" /> 中包含了一个 html。此 test.html 包含单选按钮。如何检索单选按钮的值并将其传递给操作?
问问题
126 次
2 回答
0
<s:form action="sampleAction">
<s:include value="yourjspfile.jsp"/>
<s:submit />
</s:form>
yourjspfile.jsp
<s:textfield name="name" label="Enter your name"/>
You can specify the name property in your action class and can access it directly no need to get it from the request object.
于 2012-05-04T08:49:01.827 回答
0
<s:include />
在您的主页中的表单中添加此标记。例如
<s:form action="Welcome">
<s:include value="test.jsp"></s:include>
<s:submit />
</s:form>
测试.jsp:
<input type="radio" value="abc" name="test" >abc</input>
<input type="radio" value="def" name="test" >def</input>
并在您的 Action 中命名Welcome
:
HttpServletRequest request = ServletActionContext.getRequest();
System.out.println(request.getParameter("test"));
您可以获得单选按钮的值。希望这可以帮助!
于 2012-05-04T04:35:11.593 回答