我用SSH框架,用到了AJAX,不想SSH整合AJAX,还想用Servlet+AJAX,xmlHttp.open("GET", "Vilidate?timestamp=" + new Date().getTime()+"&random=" +random, true);的时候,报错,说Vilidate这个ACTION没有找到,就是说把Vilidate这个Servlet当成了一个ACTION来处理,想问:使用SSH,还可以正常的进行servlet和jsp之间的相互跳转而不被Struts2拦截器拦截吗?错误如下:
Struts has detected an unhandled exception: Messages: There is no Action mapped for namespace / and action name Vilidate.
 
--------------------------------------------------------------------------------Stacktraces
There is no Action mapped for namespace / and action name Vilidate. - [unknown location] 

解决方案 »

  1.   

    那要检查你配置Struts时的URL-Mapping是怎么写的了,如果覆盖面太广,会有问题。可以尝试调整Mapping的顺序。
      

  2.   


    要看你web.xml里怎么配置struts的拦截路径了。是不是写的 /* ?如果是,那肯定没办法了。
    你得把它改成专门的路径如:/struts/*
    然后你就可以在web.xml添加你的Vilidate的servlet的路径。这个要单独添加。
        <servlet> 
    <servlet-name>Vilidate</servlet-name>
    <servlet-class>xxx.xxx.xxx.Vilidate</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>Vilidate</servlet-name>
    <url-pattern>/Vilidate</url-pattern>
    </servlet-mapping>
    如果你有很多单独的servlet,那么所有的都要在web.xml里添加。
      

  3.   

    明白了,那用AJAX通过JSP页面返回数据也会拦截吗?
      

  4.   

    看你struts那里怎么配置,web。xml怎么配置PS:我个人来讲struts的一般是默认.do;
    servlet具体看情况, 是根据路径, 还是根据后缀。
      

  5.   


    它自己返回的数据怎么会拦截呢。它只会拦截请求,然后根据你的请求处理事情,最后返回结果给你。如果你的ajax请求符合它的拦截条件,也会拦截。总而言之:它只拦截请求。
      

  6.   

    web.xml配置struts拦截的时候 可以配置成*.do
      

  7.   

    我的意思是通过JSP写out.print()返回数据,实验了证明不会拦截,其实也可以用ACTION返回数据,总之试了3种方法,解决了,都梳理通了,结贴!