Monday, 15 March 2010

java - Basic Spring MVC project not serving view -



java - Basic Spring MVC project not serving view -

i'm having problem getting spring mvc project serve view localhost. created project within spring tool suite using new -> spring project -> spring mvc project option. have not modified code @ all, i'm confident should work way (but isn't).

here project construction , homecontroller.java

this theoretically should bring home.jsp when go localhost, instead brings basic pivotal server page:

in homecontroller.java file, if alter @requestmapping(value) "/testing", 404 error:

finally, here servletcontext.xml (which contains viewresolver came spring mvc project template):

<?xml version="1.0" encoding="utf-8"?> <beans:beans xmlns="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xsi:schemalocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <annotation-driven /> <resources mapping="/resources/**" location="/resources/" /> <beans:bean class="org.springframework.web.servlet.view.internalresourceviewresolver"> <beans:property name="prefix" value="/web-inf/views/" /> <beans:property name="suffix" value=".jsp" /> </beans:bean> <context:component-scan base-package="pear.pear.pear" /> </beans:beans>

and web.xml file:

<?xml version="1.0" encoding="utf-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <context-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/spring/root-context.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> <servlet> <servlet-name>appservlet</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <init-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/spring/appservlet/servlet-context.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>appservlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app>

how can resolve issue? doing wrong? also, on side note, i've noticed in many other spring tutorials utilize application.java driver class - necessary?

thanks lot.

your app not running on root url in tomcat (/). default same name project, e.g. http://localhost:8080/hello/testing.

java spring spring-mvc

No comments:

Post a Comment