Hi All,
Am writing a sprig application..in this am trying to render view using
ResourceBundleViewResolver..
but am getting exception..
my properties file is under source file in eclipse..
my
jsp folder is under webcontent..
can somebody please help me out from this...
am placing my code below
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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 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">
<welcome-file-list>
<welcome-file>jsp/input.jsp</welcome-file>
</welcome-file-list>
<
servlet>
<servlet-name>Application</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Application</servlet-name>
<url-pattern>*.form</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/Application-servlet.xml
</param-value>
</context-param>
Application-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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="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">
<import resource="ApplicationContext.xml" />
<bean id="bundleViewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
<property name="basename" value="/views">
</property>
</bean>
</beans>
Applicatio-context.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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="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">
<context:component-scan base-package="com.*.controller, com.*.service, com.*.dto"/>
<!-- <context:annotation-config/> -->
</beans>
views.properties file
home.class=org.springframework.web.servlet.view.JstlView
home.url=/jsp/home.jsp
controller
@Controller
public class SampleController {
@RequestMapping("/home.form")
protected ModelAndView handleSampleRequest(HttpServletRequest request,
HttpServletResponse response, @ModelAttribute("person") Person person)throws Exception {
System.out.println("---------------entering controller");
return new ModelAndView("home", "message", person);
}
}
home.jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body bgcolor="wheat">
<h2>${message.age}</h2>
<h2>${message.name}</h2>
</body>
</html>
thanks in advance..
sachin