struts 中action问题 action怎么取jsp中的radio和checkbox的值,请各位高手指点 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1.关于Radio Button比如这里有个form.html,而且它要提交到result.jsp<form action="result.jsp" method="post"><input type="radio" value="男" name="gender"/><input type="radio" value="女" name="gender"/></form>然后在result.jsp页面中使用:<%String gender = request.getParameter("gender");out.println("<h1>" + gender + "</h1>");%>这样就行了2.关于Check Box比如这里有个form.html,而且它要提交到result.jsp<form action="result.jsp" method="post"><input type="checkbox" value="男" name="gender"/><input type="checkbox" value="女" name="gender"/></form>然后result.jsp页面中使用:<%String[] genders = request.getParameterValues("gender");for (int i=0; i<genders.length; i++){out.println("<h1>" + genders[i] + "</h1>");}%>这样就行 ......别人说是struts啊。可以在Action里用 List ,set Action:private List<String> interest; public List<String> getInterest() { return interest; } public void setInterest(List<String> interest) { this.interest = interest; }提交参数jsp: <form action="XX"> <input name="interest" type="checkbox" value="male"> <input name="interest" type="checkbox" value="female"> <input type="submit" value="submit"> </form>显示JSP:<s:property value="interest[0]"/> <s:property value="interest[1]"/> 这是struts2 的,不知道1,2是不是一样的希望对楼主有帮助 radio String radio = request.getParameter("radio");checkbox String[] checkbox = request.getParameterValues("checkbox"); 1.关于Radio Button比如这里有个form.html,而且它要提交到result.jsp<form action="result.jsp" method="post"><input type="radio" value="男" name="gender"/><input type="radio" value="女" name="gender"/></form>在你的action中定义一个String gender这样就行了2.关于Check Box比如这里有个form.html,而且它要提交到youraction<form action="result.jsp" method="post"><input type="checkbox" value="男" name="gender"/><input type="checkbox" value="女" name="gender"/></form>在你的action中定义一个String[] gender这样就行了注意:别忘记getter()和settter() 跪求jsp高手进来看看! cxf2.0.10发布的问题.weblogic(100分) 根据用户权限判断该列是否显示 axis中用jws方式发布,出现错误! 诚恳麻烦请热心人推荐下EJB开发的IDE!很是感谢。 狂晕的generator问题 在网络上传送字符流一般用那两个流呀? 大虾看看ant的build.xml文件里的一句 java虚拟机栈深度是什么意思? 添加订单判断两表是否有重复元素--js ,急急急急急急~ 求帮忙。 JFreeChart问题求助(在线等指导) 我快疯了,求高手指点,学了半年也学不会SSH
比如这里有个form.html,而且它要提交到result.jsp
<form action="result.jsp" method="post">
<input type="radio" value="男" name="gender"/>
<input type="radio" value="女" name="gender"/>
</form>
然后在result.jsp页面中使用:
<%
String gender = request.getParameter("gender");
out.println("<h1>" + gender + "</h1>");
%>
这样就行了2.关于Check Box
比如这里有个form.html,而且它要提交到result.jsp
<form action="result.jsp" method="post">
<input type="checkbox" value="男" name="gender"/>
<input type="checkbox" value="女" name="gender"/>
</form>
然后result.jsp页面中使用:
<%
String[] genders = request.getParameterValues("gender");
for (int i=0; i<genders.length; i++){
out.println("<h1>" + genders[i] + "</h1>");
}
%>
这样就行
private List<String> interest;
public List<String> getInterest() {
return interest;
} public void setInterest(List<String> interest) {
this.interest = interest;
}
提交参数jsp:
<form action="XX">
<input name="interest" type="checkbox" value="male">
<input name="interest" type="checkbox" value="female">
<input type="submit" value="submit">
</form>显示JSP:<s:property value="interest[0]"/>
<s:property value="interest[1]"/>
这是struts2 的,不知道1,2是不是一样的希望对楼主有帮助
checkbox String[] checkbox = request.getParameterValues("checkbox");
比如这里有个form.html,而且它要提交到result.jsp
<form action="result.jsp" method="post">
<input type="radio" value="男" name="gender"/>
<input type="radio" value="女" name="gender"/>
</form>
在你的action中定义一个
String gender这样就行了2.关于Check Box
比如这里有个form.html,而且它要提交到youraction
<form action="result.jsp" method="post">
<input type="checkbox" value="男" name="gender"/>
<input type="checkbox" value="女" name="gender"/>
</form>在你的action中定义一个
String[] gender这样就行了
注意:别忘记getter()和settter()