单单这么看,没有错是不是在用struts?

解决方案 »

  1.   

    <%=request.getAttribute("name")%>
      

  2.   

    <%=request.getAttribute("name")%>
      

  3.   

    是的具体一点:
    jsp中
    <html:form action="/select">
    name:=
    <%request.getAttribute("name");%>
    </html:form>struts-config.xml中
      <action-mappings>
        <action    path="/select"
                   type="classes.usermanager.SelectAction"
                  scope="request"
               validate="false">
        </action>
    ......SelectAction.java中
    public class SelectAction extends Action {
      public ActionForward execute(ActionMapping mapping,
                                   ActionForm form,
                                   HttpServletRequest request,
                                   HttpServletResponse response)
          throws Exception {
        request.setAttribute("name","aaa");    return (mapping.findForward("success"));
      }
    }只显示"name:="怎么回事?
      

  4.   

    <%out.print(request.getAttribute("name"));%>
      

  5.   

    好啦 :)改成“<%=request.getAttribute("name")%>”但是显示是"name:=null"为什么呢?
      

  6.   

    这样感觉比较怪异,
    request本来是浏览器向action发送的请求,
    为什么要用它来返回数据呢?
    是否有更合理的办法呢?
      

  7.   

    request向action请求的就是你想要显示的数据~name=<%=request.getString("name")%>试试这样看看~
      

  8.   

    <%=request.getParameter("name")%>
      

  9.   

    name=<%=request.getString("username")%>这样吧~
    getAttribute()也行的,但里面的参数必须是上一个页面form里的空间名字。我举个例子:你上一个页面form里有个type="text"的input控件,它的名字是:username,
    那么你可以用request.getString("username")来得到form里名为username的文本框里所提交的内容~
      

  10.   

    犯了个错误~是name=<%=request.getParameter("username")%> 我又把它和从数据库取值的搞混了~
      

  11.   

    修改成name=<%=request.getParameter("username")%> 还是“name:= null”555
      

  12.   

    请问一下楼主,你的成action提交成功后的页面是那个?为什么在Struts_config.xml里没有设置呢?我看了一下你的程序应该是没有什么问题,但可以就出在Struts_config.xml里了吧?*-*再有就是你在action里system一下,看到底有没有得到参数才知道在那一步没有得到,这样的话就好解决问题啦!!!!
      

  13.   

    To:squallzeng(小呆呆)
    Struts_config.xml改成:
        <action    path="/select"
                   type="classes.usermanager.SelectAction"
                  scope="request"
               validate="false">
          <forward name="success"              path="/index.jsp"/>
        </action>
    成功后,还是显示这个页面,问题没有解决。
    jsp没有得到返回的数据。
      

  14.   

    如果是Struts的问题~俺就不熟悉了~学习~
      

  15.   

    “你在action里system一下”这个的意思是在action类中System.out.println("test");?我这样做了,tomcat控制台没有输出。
      

  16.   

    action中写:
    request.setAttribute("name","aaa");jsp中写:name=<%=request.getAttribute("name")%>
    已经输出aaa,没问题
      

  17.   

    可以完整的贴出来么包括jsp action类 和 struts-config.xml谢
      

  18.   

    你在action里system.out不没有输出的话说明你在action就没有得到参数那么在你的jsp页面就肯定得不到的啦!!!!
      

  19.   

    可能是因为你在上一个页面里没在username的文本框里输入什么内容,所以报空。
      

  20.   

    这样看来,可能是我的tomcat配置有问题。我的目录结构如下:
    webapps\user-manager\index.jsp
    webapps\user-manager\WEB-INF\struts-config.xml
    webapps\user-manager\WEB-INF\classes\usermanager\SelectAction.class
    webapps\user-manager\WEB-INF\lib\struts.jar还缺什么么,为什么没有调用action呢?
      

  21.   

    既然用request取值,那总要有个取值对象~如果觉得麻烦,也可以放到session里~