struts做得用户资料修改。首先显示用户列表,然后点击某条数据进入修改界面,进入修改页后给文本框赋值时出错。
For input string: "userName"
at java.lang.NumberFormatException.forInputString
从list里点击“修改”后的action如下:
Action如下
public ActionForward modify(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
CompanyUserDAO cuDAO = new CompanyUserDAO();
XtTcCompanyUser xtcu = new XtTcCompanyUser();
String username = request.getParameter("username");
HttpSession session=request.getSession();
List<XtTcCompanyUser> listxtcu=new ArrayList<XtTcCompanyUser>();
String sql=" and 用户名称 like '%" + username + "%'";
listxtcu=cuDAO.getList(sql);
request.setAttribute("companyusermodifylist",listxtcu );
return mapping.findForward("success");
}
编辑页:
<html:form action="/**.do">
pwd : <html:text property="pwd" /><html:errors property="pwd"/><br/>
linkperson : <html:text property="linkperson" ><html:errors property="linkperson"/><br/>
usernae : <html:text property="username" value="${companyusermodifylist.userName}"//><html:errors property="username"/><br/>
<html:submit/><html:cancel/>
</html:form>username的大小写都测试了,不管用。
调试时listxtcu里也有值。
For input string: "userName"
at java.lang.NumberFormatException.forInputString
从list里点击“修改”后的action如下:
Action如下
public ActionForward modify(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
CompanyUserDAO cuDAO = new CompanyUserDAO();
XtTcCompanyUser xtcu = new XtTcCompanyUser();
String username = request.getParameter("username");
HttpSession session=request.getSession();
List<XtTcCompanyUser> listxtcu=new ArrayList<XtTcCompanyUser>();
String sql=" and 用户名称 like '%" + username + "%'";
listxtcu=cuDAO.getList(sql);
request.setAttribute("companyusermodifylist",listxtcu );
return mapping.findForward("success");
}
编辑页:
<html:form action="/**.do">
pwd : <html:text property="pwd" /><html:errors property="pwd"/><br/>
linkperson : <html:text property="linkperson" ><html:errors property="linkperson"/><br/>
usernae : <html:text property="username" value="${companyusermodifylist.userName}"//><html:errors property="username"/><br/>
<html:submit/><html:cancel/>
</html:form>username的大小写都测试了,不管用。
调试时listxtcu里也有值。
解决方案 »
- websphere在web.xml中新添加一个servlet配置不生效
- 怎么保存CropZoom插件的截图
- hql中时间比较大小
- 诡异的session 失效问题
- 谁有RUBY的中文完整教程
- 请教,有关于JSP中的权限问题,急呀。!!
- HttpServletRequest 的实现类是哪一个。jsp和servlet是在怎么通过request和 response交互的
- 请问个高手,在JSP里怎么通过递交页面动态追加SELECT列表(有几个SELECT不知道啊)--急啊
- 十分简单的问题:如何将数字转换为字符类型?
- linux下java连接mysql的常见的关键错误之一
- 求思路。
- web项目首页定时更新问题
不是你贴出来的这段代码中的问题而是你其他代码段将字符串转换为数字的问题。。
错在将“userName”这个字符串转换为数字错误检查一下 你哪里有userName,并不是userName变量,而是变量的值为userName
list里放的是XtTcCompanyUser对象,XtTcCompanyUser对象里放着userName属性 你这样写表示拿list的userName属性
value="${companyusermodifylist[0].userName}"
userName}"//>建议//去掉一个,//可能会默认被编译
按你的方法,解决了