samedi 28 février 2015

I am getting an error when I try to run a simple Spring project. Please help me

I am using the latest Spring JARS. I created a very small application where it renders Hello on a JSP.


However, it says that I have a problem in my dispatcher servlet where I declare the bean definition. Please help me. This is my hello Controller



package com.raghav.hellocontroller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

public class HelloController {

protected ModelAndView handleRequestInternal(HttpServletRequest request,
HttpServletResponse response) throws Exception {
ModelAndView modelandview = new ModelAndView("HelloPage");
modelandview.addObject("welcomeMessage","Hi User, welcome to the first Spring MVC Application");

return modelandview;
}
}


This is my web.xml



<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://ift.tt/ra1lAU" xmlns="http://ift.tt/nSRXKP" xsi:schemaLocation="http://ift.tt/nSRXKP http://ift.tt/1eWqHMP" id="WebApp_ID" version="3.0">
<display-name>SpringMVCTutorial</display-name>
<servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>spring-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>


This is my dispatcher servlet



<beans xmlns="http://ift.tt/GArMu6"
xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/1E5zs6r http://ift.tt/GAf8ZW">

<bean id="handlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMaping"/>

<bean name="/welcome.html" class="com.raghav.hellocontroller.HelloController" />

<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">

<property name="prefix">
<value>/WEB-INF/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>

Aucun commentaire:

Enregistrer un commentaire