Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

localisation problems

 
krishna Gajarla
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have written

TestController.java

package com.egatematrix.ess.controller.model;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

import org.springframework.web.servlet.*;
import org.springframework.web.servlet.mvc.*;

public class TestController implements Controller
{
public ModelAndView handleRequest(HttpServletRequest req, HttpServletResponse res) throws Exception
{
System.out.println("1");
return new ModelAndView("Home", "message", greeting);
}
private String greeting;

public void setGreeting(String greeting)
{
this.greeting=greeting;
}
}


index.jsp:

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<c:redirect url="/home.htm"/>

web.xml:

<?xml version="1.0" encoding="ISO-8859-1" ?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<servlet>
<servlet-name>cbtech</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>cbtech</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

</web-app>

messages.properties:

success=You are a Valid User

cbtech-servlet.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>
<bean name="/home.htm" class="com.egatematrix.ess.controller.model.TestController">
<property name="greeting">
<value>Welcome to Cybertech</value>
</property>
</bean>

<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>messages</value>
<value>buttons</value>
</list>
</property>

</bean>

<bean id="localeResolver" class="org.springframework.web.servlet.i18n.KookieLocaleResolver"/>

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>

</bean>
</beans>


Home.jsp:

<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>

<html>
<head><title>Spring Training, Inc.</title></head>
<body>
<h2><fmt:message key="success"/></h2>
<input type=submit class="button" value="<fmt:message key="submit"/>">
</body>
</html>


In the above code i have miss spelt Cookie as Kookie.

Can any one help me. And also i want to use Hyperlinks to change locales in jsp using interceptors. Can anyone give me the code.

Thanks in advance

Radha Krishna
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic