前台登录代码:
<s:form action="login" namespace="/" method="post" theme="simple">
<tr><td align="right" width="79">用户名:</td><td width="100"><input name="userName" type="text" class="txtitem" id="userName"/></tr>
<tr><td align="right">密 码:</td><td><input name="password" type="password" class="txtitem" id="password"/> <input name="method:login" value="1" type="hidden"/></td></tr>
<tr><td ><input type="submit" value="登录"></td></tr></s:form>jsp页面登录后是通过struts重定向到另一个jsp页面:需要得到之前登陆页的 用户名和密码。记得这是存储在session中,如何获取里面的值strutssessionjsp

解决方案 »

  1.   

    HttpSession httpSession =ServletActionContext.getRequest().getSession();
    String username = httpSession.getAttribute("userName");
    String password= httpSession.getAttribute("password");
      

  2.   

    session.setAttribute("值的名字",值对象);//往session里放值的方法
    session.getAttribute("值的名字");//从session里取值的方法
    //不过通常你获取到的只有request对象
    request.getSession().getAttribute("");//session是被封装在request里边的
      

  3.   

    能不能给个在jsp上面完整打印出来的代码,脑子不够用
      

  4.   

    可以直接在你的另一页面用小脚本来获取,session.getAttribute("userName");
    和上面给的方法一样的!
      

  5.   

    楼上的朋友说的没错,在action中将用户名和密码设置到session中
    session.setAttribute("userName",request.getParameter("userName"));
    session.setAttribute("password",request.getParameter("password"));
    //在action中获取
    request.getSession().getAttribute("userName");
    request.getSession().getAttribute("password");
    //在jsp页面获取
    <input type="text" value="<s:property value='#session.userName'/>"/>
    <input type="text" value="<s:property value='#session.password'/>"/>