大概看懂你的意思,你只要在action中把你的那个userbean,set到request中去就可以了啊,然后在页面上用struts的tag把它取出就可以了...

解决方案 »

  1.   

    在调用页面怎么用呢?我先在action 中
     request.getAttribute("user",myuser);myuser有setRole和getRole方法
    然后在调用页面:
    <%@ page import="test.util.User"%>
    <% User user=(User)request.getAttribute("user");%>
    <logic:greaterThan name="user" property="role" value="0">
    you hava the role
    </logic:greaterThan>
    结果提示错误:
     No bean found under attribute key user
      

  2.   

    是不是说用户登录之后,从数据库中取出他的权限,赋值给role,然后再转向的页面中要使用role的值?
      

  3.   

    是不是说用户登录之后,从数据库中取出他的权限,赋值给role,然后再转向的页面中要使用role的值?
    ===========================================
      

  4.   

    程序没有问题,你确定你在action中有request.setAttribute("user",myuser);
    myuser中有getRole()方法?
      

  5.   

    to  sagittarius1979(缤纷眩目的世界里 是否拥有自己的色彩)
    myuser中有getRole()方法.
    up!
      

  6.   

    <% User user=(User)request.getAttribute("user");%>
    这句后加上<% if (user == null) out.println("null");%>看看request中是否有user这个属性值
      

  7.   

    to sagittarius1979(缤纷眩目的世界里 是否拥有自己的色彩) 
    我像下面这样做,结果没有任何输出,还是一样的错误提示
    <% if (user == null) 
          out.println("nullNULLLLLLLLLLLLLL");
       else
          out.print("successssssssssssssssss");   
     %>
    to
     flyshp(天堂雨) 
    你觉的该怎么做,请多多指教。谢谢!
      

  8.   

    我在action作过判断,userRole不为空,然后把userRole放入request
    request.setAttribute("user",userRole);
      

  9.   


    加上<% if (user == null) 
          out.println("nullNULLLLLLLLLLLLLL");
       else
          out.print("successssssssssssssssss");   
     %>把
    <logic:greaterThan name="user" property="role" value="0">
    you hava the role
    </logic:greaterThan>
    这一段注释掉,
    然后看输出,如果是nullNULLLLLLLLLLLLLL,说明你的request中没有user的属性值.
      

  10.   

    OK,果然user是null.
    我在action 中把request.setAttribute改为session.setAttribute 就可以了。
    谢谢 sagittarius1979(缤纷眩目的世界里 是否拥有自己的色彩) 。不过我不清楚为什么session可以,request就不可以呢?
    我在action中是这样做的:
    request.setAttribute("user",userRole); //为什么改为session就OK?
    return mapping.findForward("success");
    success是直接跳到success.jsp页面。
      

  11.   

    因为session和request的作用范围是不同的,request.setAttribute()只对下个页面有效,而session.setAttribute()在session还没有失效时都有效.
    能用request的地方尽量用session.结贴吧
      

  12.   

    我晕啊
    能用request的地方尽量用session.
    ->
    能用request的地方尽量用request.sorry :)