spring - Why am I getting java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet error? -
spring - Why am I getting java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet error? -
i trying larn spring mvc. far have done following:
web.xml
<?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="webapp_id" version="2.5"> <display-name>springmvc</display-name> <servlet> <servlet-name>spring</servlet-name> <servlet-class> org.springframework.web.servlet.dispatcherservlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app>
spring-servlet.xml
<?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:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xsi:schemalocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <mvc:resources location="/resources/" mapping="/resources/**"/> <mvc:annotation-driven/> <context:component-scan base-package="com.awesomememe"></context:component-scan> <bean class="org.springframework.web.servlet.view.internalresourceviewresolver"> <property name="prefix" value="/web-inf/views"></property> <property name="suffix" value=".jsp"></property> </bean> </beans>
homecontroller.java
package com.awesomeme.controllers; import org.springframework.stereotype.controller; import org.springframework.ui.model; @controller public class homecontroller { public string showhomepage(model model){ model.addattribute("message","smrita awesome"); homecoming "home"; } }
home.jsp
<%@ page language="java" contenttype="text/html; charset=iso-8859-1" pageencoding="iso-8859-1"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>home page</title> </head> <body> message controller <h1>${message}</h1> </body> </html>
and directory construction looks follows:
and have added next jars :
but when seek run app next error:
what missing. suggestion of great help.
java spring spring-mvc servlets dispatcher
Comments
Post a Comment