In my Spring app, I have the following:
@RequestMapping(method = RequestMethod.GET, value = "/")
public String goHome(ModelMap map){
map.addAttribute("content", "home.jsp");
return "index";
}
@RequestMapping(method = RequestMethod.GET, value = "register")
public String getRegisterPage(ModelMap map){
map.addAttribute("content", "register.jsp");
return "index";
}
On localhost, I can access them as localhost:8080 and localhost:8080/register respectively. But when I deploy them on third party server, domain.com works fine but domain.com/register (and every other links other than domain.com) result in a 404.
Not Found
The requested URL /register was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Note:
– Both localhost and domain.com run on Tomcat 5.5 and has Servlet version 2.4
– I even changed RequestMapping value to value=”/register” but nothing changed
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Adsense</display-name>
<listener>
<listener-class>com.adsense.connection.MySqlDBPooling</listener-class>
</listener>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
Thanks for help
Got my answer here: Tomcat 404 Not Found error
In my case, it worked fine with urls like /register.do 🙂