要沉了
自己顶一下吧郁闷
大家帮忙啊
THS先
自己顶一下吧郁闷
大家帮忙啊
THS先
解决方案 »
- struts2标签与dreamweaver
- JPA的@Table与Hibernate自己的@Table的关系
- hibernate处理事务出现死锁
- 企业最看重什么?
- Action中为什么不调用Service里面的方法?
- 首先给大家拜个年,我想请教一下在struts 里怎么实现像asp.net 中的server.execute()方法呢???
- J2EE Form-based Authentication
- 提个小问题,hashcode && equals
- 关于hibernate的一个小问题,马上给分!
- 谁用EJB做BLOB字段的读写,我们讨论一下?
- 谁会编这个java程序?请帮帮忙?
- 用Struts开发WEB后,打开此网页,出现org.apache.jasper.JasperException异常,请各位帮忙解决!!
修改如下:
<html:options collection="options" labelProperty="value" property="label"/>应该是用上面这个方法!<html:option value="0"><bean:message key="select.option"/></html:option>
<html:option value="1"><bean:message key="select.option.man"/></html:option>
<html:option value="2"><bean:message key="select.option.woman"/></html:option> 你这种用法,根本就没用到form里的
request.setAttribute ("options", options);中的options
当然不能显示你要的内容了
Vector options = new Vector();
options.add(new LabelValueBean("男", "男"));
options.add(new LabelValueBean("女", "女"));
request.setAttribute ("options", options);
}
这就是你初始化的源代码 你做一次数据库查询 他查出来的字段替换掉"男", "女"就可以了
这段代码放在适合的位置就行了
reset方法是在form提交前调用的 你这么写没有用
//访问数据库
//得到ResultSet rs;
while (rs.next()) {
options.add(new LabelValueBean(rs.getString(1), rs.getString(1));
}
request.setAttribute ("options", options);
这段代码写在转到你这个jsp界面的action里面的perform()方法里就可以了
<html:options property="keyList" labelProperty="nameList" name="yourFormName"/>
</html:select>
<html:select property="sex"> <html:option value="0"><bean:message key="select.option"/></html:option>
<html:option value="1"><bean:message key="select.option.man"/></html:option>
<html:option value="2"><bean:message key="select.option.woman"/></html:option>
</html:select>
在资源文件中 : select.option.man 和select.option.woman分别是 男 女
在FORM中这样写:
public String getSex() {
return sex;
} public void setSex(String sex) {
if(sex.equals("1")){
this.sex ="男";
}else
{
this.sex ="女";
}
}
结果存储到数据库中sex字段的值是: ?
一个问号,请问在RESIN下怎么解决中文乱码,谢谢了
我用的是RESIN服务器; OS 是WIN2K; 数据库是 MYSQL。