Announcement Announcement Module
No announcement yet.
annotations problem. error: The requested resource is not available. Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • annotations problem. error: The requested resource is not available.

    I am new to spring and I am trying to create an annotations based Spring project, but my problem is that the when I submit the form, I get the error:

    type Status report

    message /

    description The requested resource (/ is not available.

    I am using Eclipse with Tomcat 6.0 and the hierarchy of the project is:

    The web.xml file is:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4">
    <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
    <load-on-startup> 1 </load-on-startup>


    SpringSongs-servlet.xml file is:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns=""

    <context:component-scan base-package=""/>

    <bean class="org.springframework.web.servlet.mvc.annotat ion.DefaultAnnotationHandlerMapping"/>

    <bean class="org.springframework.web.servlet.mvc.annotat ion.AnnotationMethodHandlerAdapter"/>

    <bean id="jspViewResolver" class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlVi ew"/>
    <property name="prefix" value="/WEB-INF/jsp/"/>
    <property name="suffix" value=".jsp"/>


    And Controller file is:

    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    public class TestController {
    	@RequestMapping(value = "/", method = RequestMethod.POST)
    	public void show(HttpServletResponse response, HttpServletRequest request){
    I can see a line in the log:
    INFO: Mapped URL path [/] onto handler 'testController'

    Can you please let me know what the issue is?
    Last edited by blinkaj; Mar 15th, 2011, 12:54 AM. Reason: wrong xml file name entered

  • #2
    Re:- annotations problem. error: The requested resource is not available.

    I just developed the same application as u have mention in the forum.
    In the web.xml

    <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
    <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>

    changes need to be done . In the contextConfigLocation tag the dispatcher-Servlet.xml need to be added so that the file get loaded on startup of server.

    In the dispatcher-Servlet.xml the below code need to be added

    <ns1:component-scan base-package="">

    <bean class="org.springframework.web.servlet.mvc.annotat ion.DefaultAnnotationHandlerMapping">
    <property name="order" value="1" />
    <bean class="org.springframework.web.servlet.handler.Bea nNameUrlHandlerMapping">
    <property name="order" value="2" />

    <bean id="viewResolver"
    class="org.springframework.web.servlet.view.Intern alResourceViewResolver"
    p:suffix=".jsp" />

    The class BeanNameUrlHandlerMapping will help U mapping the MAV object to URL.



    • #3
      correcting the path in the mapping in jsp

      thanks for your reply. I tried using your suggestion but it didn't work. Then I became pretty sure that its a path issue. So I tried ../ in jsp rather then just /, with my code which I have shown above, and it worked .

      The thing is that its not necessary to mention contextConfigLocation explicity in the web.xml. If you don't provide it, the dispatcher servlet will look for default xml file which is [servletname]-servlet.xml. You can have the bean configurations in this xml file.

      thanks again.