2

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";
}
craigcaulfield
  • 3,381
  • 10
  • 32
  • 40
  • Where are you placing your `index.jsp` ? you might need to check about it's path. – doubleH90 Aug 23 '19 at 19:34
  • https://stackoverflow.com/questions/43590008/the-origin-server-did-not-find-a-current-representation-for-the-target-resource might help you. – Alien Aug 23 '19 at 19:41
  • https://stackoverflow.com/questions/43931383/the-origin-server-did-not-find-a-current-representation-for-the-target-resource – andrea___15 Aug 24 '19 at 14:48

2 Answers2

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.

PraveenKumar Lalasangi
  • 3,255
  • 1
  • 23
  • 47
0

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.

Dexter
  • 1