Message 请求的资源[/TestJspMVC/arithmetic.action]不可用
在做JSP的MVC练习的时候,发现一直报错。
原来的xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>TestMVC</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>arithmetic</servlet-name>
<servlet-class>com.controller.ArithmeticController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>arithmetic</servlet-name>
<url-pattern>/arithmetic.action</url-pattern>
</servlet-mapping>
</web-app>
错误信息:
仔细检查发现,错的是拦截路径,代码找不到arithmetic.action 这一目标,只要把 < u rl-parrtern > 更改一下即可
<url-pattern>/</url-pattern>
这样子就能拦截所有的请求进行处理