Win a copy of Functional Design and Architecture this week in the Functional programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Localisation errors

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your reply,

i am going through...the code
 
reply
    Bookmark Topic Watch Topic
  • New Topic