SSH框架中如何在JSP界面获取下拉框中选中的值 求人帮忙解决下,JSP界面和Action层代码!谢谢、还有单选radio。如何获取值。谢谢。sshactionjsp框架 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 下拉框 用 struts 自己的标签 就可以 在底层 获得 radio、select类型的和 type="text"的取值是一样的,根据名字取就行了 如果用的是struts:JSP: <input type="radio" name="radioVal" value="1">是<input type="radio" name="radioVal" value="0">否<select name="selectVal"><option value="abc">abc<option></select>Action: 给 radioVal和selectVal设置get、set方法执行方法里面直接取就行了 在 bean 里加入属性名,在 jsp 页面里用 struts 标签,属性名写上,后台调用就可以了吧 只要你后台action里面提供一个对应的属性,有getter和setter方法,就可以读出来啊。 就举一个简单的例子,获取jsp的username和passwordpublic class LoginAction { private String username; private String password; /** * * @return */ public String go() { if ("java".equals(username) && "struts".equals(password)) { return "success"; } else { return "fail"; } } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; }}应该select里面获取是一样的,我也没试,你自己看看吧。 jquery.post方法 不太会用 有点问题 请教JAVA WEB开发分页 怎样配置urlrewrite.xml实现跨域名伪静态 url乱码问题 这样就可以防御JSP的sql注入吗? JBUILDER无发启动我用JSF写的程序。。。(在线等) ssh Context initialization failed JSP下如何调oracle9i写的存储过程~~在线等急用 上传文件 的页面提交问题(紧急!!急!!!!!) maven 命令打包的时候,本地依赖项目无法打包进来 spring+mvc+mysql 高手入~~急急急! 数据库检索,网页 相应
JSP: <input type="radio" name="radioVal" value="1">是
<input type="radio" name="radioVal" value="0">否<select name="selectVal"><option value="abc">abc<option></select>Action: 给 radioVal和selectVal设置get、set方法
执行方法里面直接取就行了
public class LoginAction {
private String username; private String password; /**
*
* @return
*/
public String go() {
if ("java".equals(username) && "struts".equals(password)) {
return "success";
} else {
return "fail";
}
} public String getPassword() {
return password;
} public void setPassword(String password) {
this.password = password;
} public String getUsername() {
return username;
} public void setUsername(String username) {
this.username = username;
}
}
应该select里面获取是一样的,我也没试,你自己看看吧。