ich ein Problem mit meinem Controller haben, dauerte es nicht die URL behandeln, wie es sein sollte, hier ist der Code:Frühling erkennt nicht mein @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";
}
hier ist die Bahn. 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>
hier ist 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>
und meine Finsternis mir dies geben, wenn ich versuche, die Seite zu erreichen:
WARNING: No mapping found for HTTP request with URI [/my-webapp/seeRoom/admin/0] in DispatcherServlet with name 'myApp'
die statische Handler Arbeit in Ordnung, aber es aussehen wie der Frühling nicht erkennt meine @PathVariable
Warum denkst du sollte es? –
Mögliches Duplikat von [PathVariable in Spring Controller] (http://stackoverflow.com/questions/9077831/pathvariable-in-spring-controller) – arseniyandru
Oder eher, was Sie glauben lässt, @ 'PathVariable' ist in der WARNUNG relevant empfangen? –