我用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]
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]
要看你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里添加。
servlet具体看情况, 是根据路径, 还是根据后缀。
它自己返回的数据怎么会拦截呢。它只会拦截请求,然后根据你的请求处理事情,最后返回结果给你。如果你的ajax请求符合它的拦截条件,也会拦截。总而言之:它只拦截请求。