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

修改资料后的问题??
用户登录后,就可以修改用户注册时的信息,用户修改用户的资料后,点击修改,我让其跳回到首页,但是显示的却是用户没有登录(用户登录后,会显示欢迎您XXX,但是我会到首页后显示的是您还没有登录)。我知道产生的原因是因为经过action,但是我如果我在修改资料成功后,重定向到登录的action会显示用户不存在,(原因是我在登录的action里面判断了用户存不存在的问题,),现在我就是不知道要怎么样跳转到一个action里面,在到首页,就可以显示用户登录后的页面。


求各位高手给出建议

//Struts2的配置文件

<!-- 用户登录 -->
<action name="loginUser" class="com.jy.action.LoginUserAction">
<result name="success">/userLogin/main.jsp</result>
<result name="input">/error.jsp</result>
<result name="error">/login.jsp</result>
</action>

<!-- 在修改完用户的信息后,在查询用户的信息 -->
<action name="updateCha" class="com.jy.action.UpdateRegsterAction">
<result name="success">/updateload.jsp</result>
</action>

<!-- 用户修改资料 -->
<action name="updateuser" class="com.jy.action.UpdateRegsterAction">
<result name="success">/updatesuccess.jsp</result>
<result name="input">/error.jsp</result>
</action>

//updateload.jsp页面

<a href="userLogin/main.jsp">点此返回首页</a>

//updatesuccess.jsp页面

<s:action name="updateCha!execute" namespace="/" executeResult="true"></s:action>


//用户登录的action类
//用户登录
public String execute(){

try {
LoginUserDao dao = new LoginUserDao();
info = dao.UserSelect(this.getName());

if(info==null){
String ming="<script>alert('用户名不存在')</script>";
this.getRequest().setAttribute("ming", ming);
return "error";
}
if(!this.getSession().getAttribute("rand").equals(this.getYazheng())){

String yan="<script>alert('验证码不正确')</script>";
this.getRequest().setAttribute("yan", yan);
return "error";
}
if(!info.getPwd().trim().equals(AddPwd.getMD5ofStr(this.getPwd().trim()))){
String mima="<script>alert('密码错误')</script>";
this.getRequest().setAttribute("mima", mima);
return "error";
}
if(info.getPwd().trim().equals(AddPwd.getMD5ofStr(this.getPwd().trim()))){
this.getSession().setAttribute("info", info);
return this.SUCCESS;
}
else{
/*登录失败清空session里面的值*/
Map session = ActionContext.getContext().getSession();
session.clear();
return this.INPUT;
}
} catch (Exception e) {

e.printStackTrace();
}

return this.INPUT;
}

//修改用户资料的action类

//在修改完用户的信息后,在根据id查询用户的信息
public String execute() throws Exception{

LoginUserDao dao = new LoginUserDao();
LoginUserInfo info = dao.UserSelect(this.getName());

this.getSession().setAttribute("info", info);

return this.SUCCESS;
}


//修改用户的信息
public String updatexin(){

try{
LoginUserDao dao = new LoginUserDao();
LoginUserInfo info = new LoginUserInfo();

info.setId(this.getId());
info.setReallyName(this.getReallyName());
info.setSex(this.getSex());
info.setAge(this.getAge());
info.setImg(this.getImg());
info.setEmail(this.getEmail());

this.getSession().setAttribute("info", info);

int i = dao.updateLoginUser(info);

if(i>0){
return this.SUCCESS;
}

} catch (Exception e) {
e.printStackTrace();
}
retur