I have a very simple problem. When in my .jsp files there is a link to ** / registration, the viewRegistration method is executed and everything works fine. Should I have a link to ** / registration / getTags? TagName = blahblah page not found. I have no idea why, because I think my requestMapping annotation looks right ... I would really appreciate your help!
CONTROLLER:
@Controller
@RequestMapping(value = "/registration")
public class HelloController {
final static Logger logger = Logger.getLogger(HelloController.class);
@RequestMapping(method = RequestMethod.GET)
public String viewRegistration(Map<String, Object> model, HttpSession session) {
...
}
@RequestMapping(value = "/getTags", method = RequestMethod.GET)
public @ResponseBody
List<Tag> getTags(@RequestParam String tagName) {
....
}
}
web.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" version="3.0">
<display-name>aa</display-name>
<servlet>
<servlet-name>xxx</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>xxx</servlet-name>
<url-pattern>/registration/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/xxx-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
xxx-servlet.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
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="movies.controller" />
<context:property-placeholder location="/WEB-INF/properties/website.properties" />
<context:component-scan base-package="com" />
<context:annotation-config />
<mvc:annotation-driven />
<bean class="org.springframework.web.servlet.view.tiles3.TilesConfigurer"
id="tilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tile/tilesJsp.xml</value>
</list>
</property>
</bean>
<mvc:resources mapping="/resources/**" location="/resources/" />
<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver"
id="viewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.tiles3.TilesView" />
</bean>
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="website" />
</bean>
</beans>
EDIT EDIT EDIT: I even tried easier:
@RequestMapping(value = "/getTags")
@ResponseBody
public List<Tag> getTags() {
String tagName="";
return simulateSearchResult(tagName);
}
but still / checkin / getTags is not working ... page not found.
source
share