我在Spring MVC中的URL映射有问题。我的目标是用这种形式映射一个url:“applicationName/app /”。春季URL映射不起作用
这里是我的web.xml:
<?xml version="1.0" ?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/app/*</url-pattern>
</servlet-mapping>
</web-app>
我的控制器:
@Controller
public class Controller {
@RequestMapping(value = "app/1")
@ResponseBody
public String test1(){
return "test1";
}
}
我尝试 “/应用程序/ 1” 和 “/程序/ 1 /”,但我的网址映射不起作用。