解决方案 »

  1.   

    web.xml配置
     <filter-mapping>
       <filter-name>struts2</filter-name>
       <url-pattern>*.action</url-pattern>
      </filter-mapping>
      
      

  2.   

    你那个是*url访问:http://localhost:8080/struts/test/hello这样就可以了
      

  3.   

    是在你原来是基础上改的吧?重启 tomact了没、
      

  4.   


    访问不了。
    我将web.xml中的
    <filter>
       <filter-name>struts2</filter-name>
       <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter><filter-mapping>
       <filter-name>struts2</filter-name>
       <url-pattern>/*</url-pattern>
    </filter-mapping>删了的话,可以访问到index.jsp的内容,但也无法访问hello.jsp
      

  5.   

     <action name="hello" method="execute">
    改成
     <action name="hello" class="com.club.web.action.HelloAction" method="execute">
    好像不只这一个错误,你先把这个改了试下,这代码哪来的?
      

  6.   

    http://localhost:8080/struts/这样默认就是访问 index.jsp页面啊 不可能访问不了啊
      

  7.   


    改了,也不行,来源:http://singandsuny.blog.163.com/blog/static/1866688220101195258138/
      

  8.   


    改了,也不行,来源:http://singandsuny.blog.163.com/blog/static/1866688220101195258138/
    下次看之前先看下评论,评论好的才看,这个好多错误
    <result name="success">/WEB-INF/page/hello.jsp</result>
    改成<result name="success">page/hello.jsp</result> 在试下
      

  9.   

    你在第4步的时候错了,
    <struts>
    <package name="default" namespace="/test" extends="struts-default">
    <!-- 下面的action缺少了个class属性  是用来指定哪个Action类的 所以如下 -->
       错误:<action name="hello"  method="execute">
       真确:<action name="hello" class="com.club.web.action.HelloAction" method="execute">
    <!-- result标签下面指定的地址是这样的 -->
        错误:<result name="success">/WEB-INF/page/hello.jsp</result>
        真确:<result name="success">page/hello.jsp</result>
       </action>
    </package>
    </struts>做完这些应该可以获取到了吧。
      

  10.   

    action是要交给对应的action类来处理的,通过<action name="***" class="***">来配置
      

  11.   

    <struts>
    <package name="default" namespace="/" extends="struts-default">
       <action name="hello" class="com.club.web.action.HelloAction">
        <result name="success">/page/hello.jsp</result>
       </action>
    </package>
    </struts>
    actio里最好指明包,同时是默认执行execute()方法
    result访问里不需要WEB-INF目录
    你在地址栏输入http://localhost:8080/struts/hello.action就ok了 
      

  12.   

    JSP页面中把第一句改为<%@page contentType="text/html; charset=UTF-8"%>
      

  13.   

    理论上Struts 2.0的Action无须实现任何接口或继承任何类型,但是,我们为了方便实现Action,大多数情况下都会继承com.opensymphony.xwork2.ActionSupport类,并重载(Override)此类里的String execute()方法。
      

  14.   

    把jsp文件不要放到web-inf下
    把page文件下的hello.jsp放到webroot下,完后再修改一下struts.xml试试 <result name="success">/page/hello.jsp</result>
      

  15.   

    大哥,怎么能在WEB-INF下存放页面呢,
    WEB-INF是Java的WEB应用的安全目录。所谓安全就是客户端无法访问,只有服务端可以访问的目录。
    如果想在页面中直接访问其中的文件,必须通过web.xml文件对要访问的文件进行相应映射才能访问。
    WEB-INF文件夹下除了web.xml外,还存一个classes文件夹,用以放置 *.class文件,这些 *.class文件是网站设计人员编写的类库,实现了jsp页面前台美工与后台服务的分离,使得网站的维护非常方便。web.xml文件为网站部署描述XML文件,对网站的部署非常重要。
    在WebRoot下建立/pages/hello.jsp  再试试
    http://localhost:8080/struts/test/hello
      

  16.   

    原来是myeclipse里设置的jdk版本与实际版本不一致照成的。唉,到现在才知道。感谢各位热心人。