2 ym184767847 ym184767847 于 2016.01.17 20:53 提问

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
wh15842400641   2016.01.18 09:07

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

wojiushiwo945you
wojiushiwo945you   Ds   Rxr 2016.01.18 14:25

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

wojiushiwo945you
wojiushiwo945you 还有这个链接,跟你的问题一模一样的:http://blog.csdn.net/liu578182160/article/details/17266879
接近 2 年之前 回复
Royal_lr
Royal_lr   Ds   Rxr 2016.01.19 10:10

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

xiaomoxn
xiaomoxn   2016.01.20 09:17

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

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!