1:spring
2:struts2获取前台数据(action中获取)
//4修改用户密码、 public String updateUserPassword() throws Exception{ Map session=ActionContext.getContext().getSession(); User user1=(User) session.get("user"); //user1.getPassword()获取的是数据库密码。||pwd1获取的是jsp输入密码 if (user1.getPassword().equals(getPwd1())) { user1.setPassword(password); userService.addOrUpdateUser(user1); session.remove("user");//它的作用是移除jsp页面输入的数据 return SUCCESS; }else{ Map request= (Map) ActionContext.getContext().get("request"); request.put("msg", "旧密码错误"); return ERROR; } }
2.2:在jsp值利用strut获取后台数据库数据
<s:form action="updateUserDetail.action" method="post"> <!--下面的"%"难 --> <s:textfield label="真实姓名" value="%{#session.user.userdetail.truename}" name="userdetail.truename"></s:textfield> <s:radio list="#{1:‘男‘,0:‘女‘ }" label="性别" value="%{#session.user.userdetail.xb}" name="userdetail.xb"></s:radio> <tr><td></td><td> <s:textfield label="出生日期" value="%{#session.user.userdetail.csrq}" name="userdetail.csrq"></s:textfield> </td> </tr> <s:textfield label="E-mail" name="userdetail.email" value="%{#session.user.userdetail.email}"></s:textfield> <s:textfield label="手机" name="userdetail.phone" value="%{#session.user.userdetail.phone}"></s:textfield> <s:textfield label="地址" name="userdetail.address" value="%{#session.user.userdetail.address}"></s:textfield> <s:submit value="确认"></s:submit> </s:form>
时间: 2024-10-11 04:12:04