如题,集成了S2SH后,直接访问JSP不能显示LIST内容,但如果在地址栏中输入localhost/list.action确显示了JSP中调用List的内容,直接访问add.jsp可以添加数据,但跳转到LIST.JSP也不显示内容,是我的struts.xml配的有问题吗?
struts.xml太长,贴部分代码:
<package name="default" extends="struts-default">
   <action name="listgb" class="listgbBean" method="list">
         <result name="success">/list.jsp</result>
   </action>
 ........

解决方案 »

  1.   

    LIST.JSP页面有问题。还有转到list.jsp页面的action里面可能也有问题!
      

  2.   

    你直接访问list.jsp当然显示不了呀,因为要经过action之后才会有准备的数据在list.jsp中显示呀。
    至于你说的可以直接访问add.jsp是因为你的添加页面可能不需要准备数据吧,一般这种情况你可以也在action中定义一个public String addUI(){return "save.jsp"};这样的话,要是不要准备数据直接转就行,也可以准备数据之后再转。
    添加之后list.jsp页面中不显示,可能是你忽略了重新请求为list.jsp页面准备数据的方法吧,这个一般是重定向实现的。
      

  3.   

    单从这个action中没看出什么问题 信息不够详细呀
      

  4.   

    肯定是没有经过list.action 直接去访问的 list.jsp
      

  5.   

    你在你的配置文件里面吧error加上,看他可以返回你想要的页面吗?
    不过单从你的配置文件看不出什么信息的
    2楼说的很正确
      

  6.   

    新手看到这么多人的关心,感动ing,我表达的意思应该是,我一访问主页面list.jsp,就直接显示带数据的内容,而不是通过链接再访问list.action。这应该如何实现?是不是STRUTS2过滤不直接从jsp显示数据,而是非得带有action才自动显示jsp内容。
      

  7.   

    因为一般人们访问主页都是index.jsp,这样在struts2中设置主页也起作用啊。
      

  8.   


    你直接访问JSP页面 页面中的数据如果要通过action来显示的话 不请求action JSP页面当然拿不到数据了
      

  9.   

    搜索后有人给出这样的答案,不知道能不能行:
    index.jsp 中这样
    html code
    <body><jsp:forward page="showindex.action"></jsp:forward></bodyshowindex.action 是首页的action ,执行后实际跳转到action 对应的视图所以经过两次服务器端的转发,地址栏还是:http://localhost/index.jsp而且如果你的web.xml中的welcome file 中设置index.jsp 作为欢迎页
    那么 http://localhost 就直接访问的是showindex.action执行后的视图页面.记得web.xml中设置如下xml code
    <!- struts2的过滤器 -><filter><filter-name>struts2</filter-name><filter-class>org.apache.struts2.dispatcher.filterdispatcher</filter-class></filter><filter-mapping><filter-name>struts2</filter-name><url-pattern>*.action</url-pattern><dispatcher>request</dispatcher><dispatcher>forward</dispatcher><dispatcher>include</dispatcher></filter-mapping><filter-mapping><filter-name>struts2</filter-name><url-pattern>*.jsp</url-pattern></filter-mapping>
      

  10.   

    我在web.xml把主页直接设置成index.action也不行
      

  11.   

    准备结贴了。add跳转的问题我已经搜到了办法,加了重定向属性后直接跳转到list.action没有问题了。想直接浏览index.jsp显示list内容还是没有找到好办法,但我问题可能也提的不准确,我再自己学习学习再说。