struts.xml
<action name="loginAction" class="loginAction" method="doLogin">
<result name="l_success">/index.jsp</result>
<result name="l_faile">/login.jsp</result>
<result name="input">/login.jsp</result>
</action>login.jsp<div align="center" style="margin-top:200px">
<s:fielderror/>
<form action="loginAction.action" method="Post">
<table height="100" border="3">
<tr>
<td>用户名:</td>
<td><input type="text" name="userName"></td>
</tr>
<tr>
<td>密 码:</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="登录"> <input type="button" value="注册"/></td>
</tr>
</table>
</form>
</div>
LoginActionpublic String doLogin() {
return "l_success";
} public void validateDoLogin() {
if (userName == null || userName.equals("")) {
addFieldError("user.userName","请输入用户名!");
}
if (password == null || password.equals("")) {
addFieldError("user.userPassword","请输入密码!");
}
if (userName.length() > 15 || userName.length() < 5) {
addFieldError("user.userName","用户名不能大于15或小于5个字符!");
}
if (password.length() > 20|| password.length() < 5) {
addFieldError("user.userPassword","密码不能大于20或小于5个字符!");
} }为什么连续点击登录总是连上一次的错误信息都从fileError中取出啊,连续点击两次,如下
* 请输入用户名!
* 用户名不能大于15或小于5个字符!
* 请输入用户名!
* 用户名不能大于15或小于5个字符!
* 请输入密码!
* 密码不能大于20或小于5个字符!
* 请输入密码!
* 密码不能大于20或小于5个字符!
<action name="loginAction" class="loginAction" method="doLogin">
<result name="l_success">/index.jsp</result>
<result name="l_faile">/login.jsp</result>
<result name="input">/login.jsp</result>
</action>login.jsp<div align="center" style="margin-top:200px">
<s:fielderror/>
<form action="loginAction.action" method="Post">
<table height="100" border="3">
<tr>
<td>用户名:</td>
<td><input type="text" name="userName"></td>
</tr>
<tr>
<td>密 码:</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="登录"> <input type="button" value="注册"/></td>
</tr>
</table>
</form>
</div>
LoginActionpublic String doLogin() {
return "l_success";
} public void validateDoLogin() {
if (userName == null || userName.equals("")) {
addFieldError("user.userName","请输入用户名!");
}
if (password == null || password.equals("")) {
addFieldError("user.userPassword","请输入密码!");
}
if (userName.length() > 15 || userName.length() < 5) {
addFieldError("user.userName","用户名不能大于15或小于5个字符!");
}
if (password.length() > 20|| password.length() < 5) {
addFieldError("user.userPassword","密码不能大于20或小于5个字符!");
} }为什么连续点击登录总是连上一次的错误信息都从fileError中取出啊,连续点击两次,如下
* 请输入用户名!
* 用户名不能大于15或小于5个字符!
* 请输入用户名!
* 用户名不能大于15或小于5个字符!
* 请输入密码!
* 密码不能大于20或小于5个字符!
* 请输入密码!
* 密码不能大于20或小于5个字符!
解决方案 »
- ServletContext获取properties文件内容
- 在jsp页面里把textarea传入oracle数据库,中文乱码,怎么解决?
- 一个小问题,如何自动给一段文字添加html标识符?
- 请教关于用JSP编写网络硬盘
- Collection ret=new ArrayList();错了吗??不解,请指教!!
- 弱弱的问:Servlet和Bean的区别是什么啊?
- 请教IE和netscape的javascript的问题 附代码
- 求救:用jsp技术如何实现套打?
- 一个幼稚的问题,大家都用什么做网页?
- 怎么样循环读出文本文件里的所有数据?
- 查询语句时用索引好还是用字段名好为什么?
- 刚入职,做java web项目,有什么好的建议
是这样子的,spring注入的类默认是单例的,即scope="singleton",所以你所有的请求都是 一个同一个实例,错误信息就累积起来了,只要把注入的bean中加scope="prototype"就可以了。。加油~~