日期:2014-05-17  浏览次数:20947 次

jsp页面传值hidden的用法,最好有例子(急)
jsp页面传值hidden的用法,最好有例子

------解决方案--------------------
jsp页面
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%> 
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
 
<html> 
<head>
<title>JSP for DynaValidatorForm form</title>
</head>
<html:javascript formName="systemUserForm"/>
<script type="text/javascript">
function passwordCheck()
{
if(document.systemUserForm.userPwdChk.value!=document.systemUserForm.userPwd.value)
{
document.systemUserForm.userPwdChk.value="";
document.systemUserForm.userPwd.value="";
document.systemUserForm.userPwd.focus();
window.alert("用户输入的密码和验证密码不同,请重新输入!");
}
}
</script>
<body>
<center>
<html:form action="/systemUser" onsubmit="return validateSystemUserForm(this)">
<html:hidden property="method"value="save"/>
<html:errors name="insertSystemUser"/>
<bean:message key="systemUSer.addSystemUser.display.regInfo"/><br>
<bean:message key="systemUSer.addSystemUser.display.userName"/>:<html:text property="userName"/><br>
<bean:message key="systemUSer.addSystemUser.display.userPwd"/>:<html:password property="userPwd"/><br>
<bean:message key="systemUSer.addSystemUser.display.userPwdChk"/>:<html:password property="userPwdChk" onblur="passwordCheck()"/><br>
<bean:message key="systemUSer.addSystemUser.display.userPhone"/>:<html:text property="userPhone"/><br>
<bean:message key="systemUSer.addSystemUser.display.userEmail"/>:<html:text property="userEmail"/><br>
<html:submit><bean:message key="systemUSer.display.submit"/></html:submit><html:reset><bean:message key="systemUSer.display.reset"/></html:reset>
</html:form></center>
</body>
</html>
action 类:

 public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {

String uri = request.getServletPath()
+ (request.getPathInfo() == null ? "" : request.getPathInfo());
System.out.println(uri);
System.out.println("request.getServletPath()"+request.getServletPath());
System.out.println("request.getPathInfo()"+request.getPathInfo());

if (!this.isTokenValid(request)) {
ActionMessages errors = new ActionMessages();
errors.add("insertSystemUser", new ActionMessage("errors.insertSystemUser"));
this.saveErrors(request, errors);
// this.saveToken(request);
this.resetToken(request);
return mapping.getInputForward();
} else {
this.resetToken(request);
DynaValidatorForm f = (DynaValidatorForm) form;
String userId = request.getParameter("userId");
SystemUser user = null;
if (userId == null) {
user = new SystemUser();
user.setUserName((String) f.get("userName"