| Author |
Localisation errors
|
krishna Gajarla
Greenhorn
Joined: Oct 02, 2005
Posts: 21
|
|
Hi, I am trying to run an application to implemet localisation. SpringappController.java is : package com.cybertech; import org.springframework.web.servlet.mvc.Controller; import org.springframework.web.servlet.ModelAndView; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public class SpringappController implements Controller { /** Logger for this class and subclasses */ protected final Log logger = LogFactory.getLog(getClass()); public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("1"); logger.info("SpringappController - returning hello view"); return new ModelAndView("hello.jsp"); } } springapp-servlet.xml is: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <!-- - Application context definition for "springapp" DispatcherServlet. --> <beans> <bean id="springappController" class="com.cybertech.SpringappController"/> <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <props> <prop key="/hello.htm">springappController</prop> </props> </property> </bean> <bean id="bundleViewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver"> <property name="basename"> <value>views</value> </property> </bean> </beans> web.xml is: <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 'http://java.sun.com/dtd/web-app_2_3.dtd'> <web-app> <servlet> <servlet-name>springapp</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet> <servlet-name>SpringappController</servlet-name> <servlet-class>com.cybertech.SpringappController</servlet-class> </servlet> <servlet-mapping> <servlet-name>springapp</servlet-name> <url-pattern>*.htm</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>SpringappController</servlet-name> <url-pattern>/SpringappController</url-pattern> </servlet-mapping> <taglib> <taglib-uri>/spring</taglib-uri> <taglib-location>/WEB-INF/spring.tld</taglib-location> </taglib> </web-app> hello.jsp is: <%@ taglib uri="/WEB-INF/spring.tld" prefix="spring" %> <html> <head> <title>Example :: Spring Application</title> </head> <body> <spring:message code="hello.username"/><br> <input type="submit" value="Submit"> <input type="reset" value="Reset"> </body> </html> and i have written two proeprties files views_en_US.properties views_it_IT.properties I am getting an error: org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hello': Instantiation of bean failed; nested exception is java.lang.IllegalStateException: Bean definition does not carry a resolved bean class org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:406) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:348) javax.servlet.http.HttpServlet.service(HttpServlet.java:689) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
|
Thanks and Regards,<br />krishna<br />------------------<br />Charles Darwin: <br />"It is not the strongest of the species that survives, <br />nor the most intelligent, <br />but the one most responsive to change"
|
 |
Jordi Monn�
Greenhorn
Joined: Feb 28, 2006
Posts: 21
|
|
Hello Krishna. Seems like you are trying to configure your i18n with a ViewResolver and it is impossible. ViewResolver interface has been created to achieve other issues. To achieve the i18n for your application you need to configure the messageSource interface. For example: messages and errors are a properties files, messages_it_IT.properties for example. Then, if you want a way to change the language of your web application you just have to add a localeInterceptor like this: If you want to change the language you need something like <a href="login.html?language=it_IT"> The locale will be kept in a cookie. Note: replace &CookieLocaleResolver for CookieLocaleResolver. I can't post without "&" symbol. Regards, Jordi. [ November 03, 2006: Message edited by: Jordi Monn� ]
|
 |
krishna Gajarla
Greenhorn
Joined: Oct 02, 2005
Posts: 21
|
|
Thank you for your reply, i am going through...the code
|
 |
 |
|
|
subject: Localisation errors
|
|
|