登录页面存在问题,该怎么解决?
j2ee吧
全部回复
仅看楼主
level 9
1.如果第一次填写正确的用户名和密码时,登录成功;如果第一次不填写用户名和密码时,会提示以上错误,而第二次填写正确的用户名和密码时,仍会提示这个错误,这是为什么?
多次不填写用户名和密码时,会出现重复的提示,怎么解决?
主要的程序代码如下:
login.jsp
<s:fielderror cssStyle="color:red">
<s:param>user.uname</s:param>
</s:fielderror>
用户名:<input type="text" name="uname">
<s:fielderror cssStyle="color:red">
<s:param>user.password</s:param>
</s:fielderror>
密码:<input type="password" name="password">
LoginAction.java
public String execute() throws Exception
{
User user=userService.checkUser(uname, password);
if(user==null){
System.out.println("用户不存在");return INPUT;}
else{
ActionContext.getContext().getSession().put("uno", user.getUno());
ActionContext.getContext().getSession().put("uname", user.getUname());
ActionContext.getContext().getSession().put("password", user.getPassword());
return SUCCESS;}
}
public void validate(){
if(this.getUname()==null || "".equals(this.getUname().trim()))this.addFieldError("user.uname", "请填写用户名");
if(this.getPassword()==null || "".equals(this.getPassword().trim()))this.addFieldError("user.password", "请填写密码");
}
路过的大虾们,帮帮小弟吧,不甚感激!!!
2013年03月26日 03点03分 1
level 9
这儿咋没什么人啊。。。
2013年03月28日 05点03分 2
流比
2013年07月21日 13点07分
level 7
你清理了吗?
2013年04月08日 04点04分 3
level 9
该怎么清理呢?是不是有缓存影响的,我一头雾水,求指点迷津...
2013年04月08日 13点04分 4
level 3
刷新之后再输入密码试试
代码贴的不全
要是还没解决的话,PM我吧
2013年04月11日 08点04分 5
刷新早试过咯 还是不能解决 要不留个Q(我的1063060523 加我时提醒我一下哈) 我把代码发给你 ^_^
2013年04月13日 03点04分
level 1
出现错误提示后方输入框获取焦点后用js把提示给去掉
2013年04月15日 15点04分 6
嗯 很有道理 我试试看[飞吻]
2013年04月16日 08点04分
level 1
你的action是单例,还是多例的啊。
2013年04月17日 05点04分 7
说真的,我也不清楚我写的是单例,还是双例?我刚在网上查了,应该是单例。。。
2013年04月17日 07点04分
配置文件拿出来看一下
2013年04月18日 01点04分
回复 wsqinwei00 :内容超咯,我重新跟贴了,不要见怪。。。 谢谢你的耐心解答。。。
2013年04月18日 16点04分
level 9
struts.xml:
<action name="log" class="LoginAction">
<result>/index.jsp</result>
<result name="input">/login.jsp</result>
</action>
applicationContextTX.xml:
<bean id="LoginAction" class="com.blue.web.LoginAction">
<property name="userService" ref="userService"></property>
</bean>
2013年04月18日 16点04分 8
level 9
谢谢各位好心人的帮忙。。。
很快乐。。。[微笑]
2013年04月18日 16点04分 9
level 9
我在网上查找相关的资料,struts2中action确实有单例和多例之分,Spring的bean可以针对每一个设置它的scope,如果是单例,就在spring的bean配置中设置scope="prototype",该问题就解决咯。。。
2013年04月20日 11点04分 10
level 9
[臭美]O(∩_∩)O谢谢大家的帮助。。。
2013年04月20日 11点04分 11
level 1
现在居然还有人用struts 1.x
2013年06月06日 14点06分 13
应该不是吧 我学的是2的 1的没学过 也没见过
2013年06月13日 15点06分
level 11
小白你好,小白再见
2013年06月07日 00点06分 14
小念好[握手]
2013年06月13日 15点06分
level 6
郁闷,这两天接手了公司一个struts1的项目,我很无语啊。。。一直用的SSH框架,
struts1早忘了。。。
2013年06月13日 00点06分 15
加油哦[]
2013年06月13日 15点06分
1