Action :
String name = request.getParameter("name"); //获取登陆用户名称
ActionContext.getContext().getSession().put("nsrname", name);-----------
<th>欢迎您,</th>
   <td>
    <s:property value="#session.nsrname"/>
   </td>
</tr><tr>
   <th>
      <a href="">注销</a>
   </th>
  </tr>-------------
这里的注销 怎么实现 谢谢了。

解决方案 »

  1.   

    ActionContext.getContext().getSession().invalidate()
      

  2.   


    <%
    if(session.getAttribute("name")!=null)//判断用户名是不是为空
    {
    session.removeAttribute("name");//注销
    }out.println("<script>alert('您已成功注销登录!');this.location.href='index.jsp';</script>");//回到首页
    %> 我怎么把以上代码 加入到 
    <input type="button" value="注销" onclick=""/>
      

  3.   

    点击注销链接到另一个jsp页面,该页面存放以上代码
      

  4.   


    点击注销的时候肯定有跳转到一个jsp页面,或者action了,看你是struts2做的,你就直接跳转到action里面的一个方法里,然后移除你的session了,
    可能你已经定义了一个submit了,但是你可以在button里写个onclick事件
    window.location="请求action某个方法的地址"
      

  5.   


    在action里怎么做 ??
    直接这样写嘛??
    public String logoutLogin(){
    Map session = ActionContext.getContext().getSession();
    session.clear();
    return "registerSuccess";

    }
      

  6.   

    session.remove("你以前绑定时的名字");
      

  7.   

    把你绑定在session里的那个用户信息清楚就行了吧。其余的就看你具体情况了。