This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Spring and the fly likes problem in ResourceBundleViewResolver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "problem in ResourceBundleViewResolver" Watch "problem in ResourceBundleViewResolver" New topic
Author

problem in ResourceBundleViewResolver

sachin roy
Greenhorn

Joined: Jan 30, 2012
Posts: 7
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
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1672
    
    7

Please edit your post and UseCodeTags. There is a lot of code there and its hard to read if its not formatted.

but am getting exception..


Always post the full stack trace for your exception. Otherwise we can't easily identify what the problem is.


[How To Ask Questions][Read before you PM me]
sachin roy
Greenhorn

Joined: Jan 30, 2012
Posts: 7
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..
abd i used annotations in my controller class..

can somebody please help me out from this...

am placing my code below


web.xml



Application-Servlet.xml



views.properties file
home.class=org.springframework.web.servlet.view.JstlView
home.url=/jsp/home.jsp


thanks in advance..
sachin
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1672
    
    7

Sachin,

Thanks for using the code tags, but you have forgotten once again to post the full stack trace for the exception you are receiving. Without providing us with this information we cannot really know what kind of problem we are looking for.

but am getting exception..


What kind of exception? What is the stack trace? Is it on start-up or at runtime?
sachin roy
Greenhorn

Joined: Jan 30, 2012
Posts: 7
Hi Bill Gorder,

that issue is solved..

in views.properties i just changed below declaration.. its worked fine..

home.(class)=org.springframework.web.servlet.view.JstlView

Thanks Bill.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in ResourceBundleViewResolver