Click here to Skip to main content
15,888,277 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am creating environment for setting up a spring project using maven , spring.

when i run the project on tomcat server. These URLs are working fine.

http://localhost:8080/assignment2_farooqab/index.jsp[^]

This URL is also working ok

http://localhost:8080/assignment2_farooqab/welcome/[^]

But i am getting error while trying to execute this URL
http://localhost:8080/assignment2_farooqab/WEB-INF/pages/index.jsp[^]

The Error is
HTTP Status 404
The resource is not available


I think the problem is due to this file mvcdispather xml

XML
<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="
       http://www.springframework.org/schema/beans     
       http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
       http://www.springframework.org/schema/context 
       http://www.springframework.org/schema/context/spring-context-3.2.xsd">

        <context:component-scan base-package="no.uio.inf5750.assignment2_farooqab" />

        <bean
                class="org.springframework.web.servlet.view.InternalResourceViewResolver">
                <property name="prefix">
                        <value>/WEB-INF/pages/</value>
                </property>
                <property name="suffix">
                        <value>.jsp</value>
                </property>
        </bean>

</beans>



BaseController.java file is

Java
package no.uio.inf5750.assignment2_farooqab.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.PathVariable;

 
@Controller
public class BaseController {

        @RequestMapping(value="/", method = RequestMethod.GET)
        public String welcome(ModelMap model) {

                model.addAttribute("message", "Maven Web Project + Spring 3 MVC - welcome()");

                //Spring uses InternalResourceViewResolver and return back index.jsp
                return "index";

        }

        @RequestMapping(value="/welcome/{name}", method = RequestMethod.GET)
        public String welcomeName(@PathVariable String name, ModelMap model) {

                model.addAttribute("message", "Maven Web Project + Spring 3 MVC - " + name);
                return "index";

        }

}


Any tips??
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900