xml - I have written simple code using "netbeans 8.0 spring 3.2.7", however I'm getting an error as "HTTP Status 404 - Not Found GlassFish Server 4.1 " -


i have written simple code using netbeans 8.0 spring 3.2.7, i'm getting error

http status 404 - not found type status report message not found descriptionthe requested resource not available. glassfish server open source edition 4.1

here code:

@controller public class mycontroller {     @requestmapping     public modelandview index()     {         modelandview mv=new modelandview("index");         mv.addobject("message", "this spring mvc testing using netbeans 8.0");         return mv;     } } 
<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans"    xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"    xmlns:p="http://www.springframework.org/schema/p"    xmlns:aop="http://www.springframework.org/schema/aop"    xmlns:tx="http://www.springframework.org/schema/tx"    xmlns:context="http://www.springframework.org/schema/context"    xmlns:mvc="http://www.springframework.org/schema/mvc"    xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd "> <context:component-scan base-package="com.pack" /> <mvc:annotation-driven /> <bean id="viewresolver"       class="org.springframework.web.servlet.view.internalresourceviewresolver"       p:prefix="/web-inf/jsp/"       p:suffix=".jsp" /> </beans>  <?xml version="1.0" encoding="utf-8"?> <web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee"   xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> <context-param>     <param-name>contextconfiglocation</param-name>     <param-value>/web-inf/applicationcontext.xml</param-value> </context-param> <listener>     <listener- class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> <servlet>     <servlet-name>dispatcher</servlet-name>     <servlet  class>org.springframework.web.servlet.dispatcherservlet</servlet-class>     <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping>     <servlet-name>dispatcher</servlet-name>     <url-pattern>/</url-pattern> </servlet-mapping> <session-config>     <session-timeout>         30     </session-timeout> </session-config> <welcome-file-list>     <welcome-file>/</welcome-file> </welcome-file-list> </web-app> 
<html> <head>     <meta http-equiv="content-type" content="text/html; charset=utf-8">     <title>welcome spring web mvc project</title> </head> <body>     <p>hello! ${message} </p> </body> </html> 

please add value parameter @requestmapping @requestmapping(value="/")

and change dispatcher org.springframework.web.servlet.dispatcherservlet 1


Comments