我有我的控制器的一个问题,它没有处理URL时,它应该是,这里是代码:春天没有检测到我@pathvariable
@RequestMapping(value = "seeRoom/{user}/{id}")
public String getSeeMessage(@PathVariable("user") String user, @PathVariable("id") int id, Model model) {
System.out.println(id);
return "room";
}
这里是网络。 XML:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<servlet>
<servlet-name>mif03</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>myApp</servlet-name>
<url-pattern>/backoffice</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>mif03</servlet-name>
<url-pattern>/users</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>myApp</servlet-name>
<url-pattern>/seeRoom/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/myApp-servlet.xml</param-value>
</context-param>
</web-app>
这里是myApp.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:component-scan base-package="controller" />
<context:component-scan base-package="model" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/" />
<property name="suffix" value=".jsp" />
</bean>
和我的日食给我这个当我尝试访问该页面:
WARNING: No mapping found for HTTP request with URI [/my-webapp/seeRoom/admin/0] in DispatcherServlet with name 'myApp'
静态处理,做工精细,但它看起来像春天没有检测到我@PathVariable
你为什么认为它应该? –
[PathVariable in Spring Controller]可能的重复(http://stackoverflow.com/questions/9077831/pathvariable-in-spring-controller) – arseniyandru
或者,您觉得'@ PathVariable'与警告相关吗?收到? –