'How to fix 404 error, The origin server did not find a current representation for the target resource or is not willing to disclose that one exists
When I am trying to execute @RequestMapping("/showForm")
I am facing an error.
I think my code seems fine, I am simply returning new String with the name of my JSP file - "mainmenu.jsp". I have this folder the folder JSP in the right place. The error:
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Where can be the problem?
<mvc:annotation-driven />
<context:component-scan
base-package="com.crunchify.controller" />
<mvc:default-servlet-handler />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<servlet>
<servlet-name>crunchify</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>crunchify</servlet-name>
<url-pattern>/welcome.jsp</url-pattern>
<url-pattern>/mainmenu.jsp</url-pattern>
<url-pattern>/mainmenu.html</url-pattern>
<url-pattern>/processForm.jsp</url-pattern>
<url-pattern>/processForm.html</url-pattern>
<url-pattern>/index.jsp</url-pattern>
<url-pattern>/main-menu.jsp</url-pattern>
<url-pattern>/welcome.html</url-pattern>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
The actual request:
@RequestMapping("/showForm")
public String helloWorld() {
return "mainmenu";
}
Solution 1:[1]
Your deployment descriptor(web.xml) does not have mapping for the url you are trying to access. Either add "/showForm" in url mapping for dispatcher servlet or use a wild card "/" in your url mapping for your dispatcher servlet. like,
<servlet>
<servlet-name>crunchify</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>crunchify</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
As web.xml is the entry point, there should be url mapping.
(And also you can map different url for different dispatcher servlet. In other dispatcher servlet you can use another view resolver.)
Hope <url-pattern>/</url-pattern>
it will work for you.
Solution 2:[2]
Go to your apache web server config, its probably in ProgramFiles > Apache Tomcat folder Go to tomcat>conf folder Edit server.xml Search "Connector port" Look for the connection timeout, if its set to -1 then that is the issue Change it to "20000", save the file. Restart the Apache Service
Problem will be fixed.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Dexter |