ym184767847
ym184767847
2016-01-17 12:53
采纳率: 0%
浏览 3.6k

struts配置web.xml提示not assignable to 'javax

struts配置web.xml提示org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter' is not assignable to 'javax.servlet.Filter
导入的包和报错情况如下:
图片说明
项目运行报错
WARNING: Could not find action or result
There is no Action mapped for namespace [/] and action name [learn] associated with context path []. - [unknown location]
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:553)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:617)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1778)
at java.lang.Thread.run(Thread.java:724)

struts配置如下
    <package name="xxx" extends="struts-default">
    <action name="learn" class="main\java\action\HelloAction" method="execute">
        <result name="success">/success.jsp</result>
    </action>
</package>
    HelloAction.java文件如下

public class HelloAction extends ActionSupport{
@Override
public String execute() throws Exception {
System.out.println("正在访问action");
return "success";
}
}

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

4条回答 默认 最新

  • wh15842400641
    Run丶Boy 2016-01-18 01:07

    class="main\java\action\HelloAction" 导入的时候不是用 \ 而是用 . ,改成 class="main.java.action.HelloAction"试试

    点赞 评论
  • wojiushiwo945you
    毕小宝 2016-01-18 06:25

    你的Struts2.xml的配置可能有问题,class的值是类的全路径名称,是用.分割包名的。
    参考下这个:http://www.cnblogs.com/gulvzhe/archive/2011/11/21/2256632.html

    点赞 评论
  • Royal_lr
    Royal_lr 2016-01-19 02:10

    main\java\action\HelloAction,,不知道你这样是在哪里学的

    点赞 评论
  • xiaomoxn
    xiaomoxn 2016-01-20 01:17

    class="main\java\action\HelloAction" 是包名+类名,要用.连接,换成class="main.java.action.HelloAction"试一下

    点赞 评论

相关推荐