在struts1的action里想获得 jsp页面上radio里选的值
插入到数据库中
属性是sex(性别)类型String 界面上该怎么定义 <td>性别</td>
<td>
<input name="connectorType" type="radio" value="1"/>亲人
<input name="connectorType" type="radio" value="2"/>朋友
<input name="connectorType" type="radio" value="3"/>同事
</td> Action中该怎么写 语句???? 一、是先用javascript在页面上获取radio的value值,然后设置一个变量保存,再在action里获取这个变量吗?二、还是直接在action里面写如下代码:
DynaValidatorForm addStudentForm = (DynaValidatorForm)form;
String connectorType =null;
String radio = (String) addStudentForm.get("connectorType");
if(radio=="1")
connectorType ="Relative";
if(radio=="2")
connectorType ="Friend";
if(radio=="3")
connectorType ="Colleague";
但是第二种方法不可行啊???怎么办???
插入到数据库中
属性是sex(性别)类型String 界面上该怎么定义 <td>性别</td>
<td>
<input name="connectorType" type="radio" value="1"/>亲人
<input name="connectorType" type="radio" value="2"/>朋友
<input name="connectorType" type="radio" value="3"/>同事
</td> Action中该怎么写 语句???? 一、是先用javascript在页面上获取radio的value值,然后设置一个变量保存,再在action里获取这个变量吗?二、还是直接在action里面写如下代码:
DynaValidatorForm addStudentForm = (DynaValidatorForm)form;
String connectorType =null;
String radio = (String) addStudentForm.get("connectorType");
if(radio=="1")
connectorType ="Relative";
if(radio=="2")
connectorType ="Friend";
if(radio=="3")
connectorType ="Colleague";
但是第二种方法不可行啊???怎么办???
解决方案 »
- swfupload上传成功后,如何重置其上传个数?
- ***********cas ssi 单点怎么跳过cert认证***********
- SSH中出现MappingException,让我很不解,望各位前辈指教
- 请帮忙做几道 EJB 的题目
- 请大侠出手介绍一下JMX和MBeans!谢谢!
- 崩溃了,JMS的UIL2报错!大送分!!
- 如何实现hao123网站中“添加网址”功能
- 谁帮我解决了TUTORIAL1.4里面的BANK的问题我给他30元,,骗人是狗。
- ECLIPSE里在工程上右键有一项TOMCAT菜单,请问这个菜单是怎么弄出来的.
- 请问哪能弄到有关spring入门的中文资料!
- mybatis进行多表查询时,建视图?关系映射?还是直接返回Map?困扰了我N久,诚心求教
- No result defined for action XX.UserAction and result success
这句话已经获取到你的radio值了
至于后面的判断就不要了,前台jsp中radio会有一个默认的check=checked,被选中的radio就会被传到action中
String radio = (String) addStudentForm.get("connectorType");
先看清楚了再说
<html:radio property="connectorType" value="2" ></html:radio>
<html:radio property="connectorType" value="3" ></html:radio>
你自己试下
String stuSex = studentForm.getStudentSex();
StudentForm 中有这个属性studentSex,且在页面上绑定。