Jsp 如何在SpringMVC中使用国际化
我希望我的应用程序支持多个语言环境,我有特定于语言环境的属性 消息\u en.properties: 消息\u fr.properties: 下面是我的servlet-context.xmlJsp 如何在SpringMVC中使用国际化,jsp,spring-mvc,Jsp,Spring Mvc,我希望我的应用程序支持多个语言环境,我有特定于语言环境的属性 消息\u en.properties: 消息\u fr.properties: 下面是我的servlet-context.xml /WEB-INF/views/ .jsp login.jsp: EIDSAR登录页面 ${sessionScope[“SPRING\u SECURITY\u LAST\u EXCEPTION”].message} 登录 但是当我从EN导航到FR时,我没有在FR中获得用户名 谁能帮帮我
/WEB-INF/views/
.jsp
login.jsp:
EIDSAR登录页面
${sessionScope[“SPRING\u SECURITY\u LAST\u EXCEPTION”].message}
登录
但是当我从EN导航到FR时,我没有在FR中获得用户名
谁能帮帮我,我做错了什么?任何帮助都将不胜感激。您好,文件放在哪里(messages\u fr.properties,messages\u en.properties)在项目结构中,我在/eidsar/src/main/resources/messages_en.properties以及/eidsar/src/main/webapp/WEB-INF/classes/messages_en.properties下放置了将源附加到mailmebaskeran@gmail.com我明白了!谢谢你的回复!我不得不用,
login.username=User Name:
login.username=Nom d'utilisateur:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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 http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:component-scan base-package="com.mobistar.eidsar.controller" />
<context:property-placeholder location="classpath:validation.properties"/>
<mvc:annotation-driven />
<mvc:resources mapping="/images/**" location="/WEB-INF/images/" />
<mvc:resources mapping="/css/**" location="/WEB-INF/css/" />
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames" value="validation, messages" />
</bean>
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
<property name="defaultLocale" value="en" />
</bean>
<bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang" />
</bean>
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" >
<property name="interceptors">
<list>
<ref bean="localeChangeInterceptor" />
</list>
</property>
</bean>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/views/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link href="/eidsar/css/headerStyle.css" rel="stylesheet">
<link href="/eidsar/css/pageStyle.css" rel="stylesheet">
<title>EIDSAR-Login Page</title>
</head>
<body>
<div>
<div id="header-top">
<a href="/eidsar" title="Logo">
<img class="logo" src="/eidsar/images/MobistarLogo.jpg" />
</a>
<ul class="lang-nav">
<li><a id="active" href="?lang=en" title="en">EN</a></li>
<li><a href="?lang=fr" title="fr">FR</a></li>
<li><a href="?lang=nl" title="nl">NL</a></li>
</ul>
</div>
<div id="header-bottom">
<div style="visibility:hidden" id="header-content">
<ul class="head-nav"></ul>
</div>
</div>
</div>
<c:if test="${not empty error}">
<div class="errorblock"><spring:message code="login_unsuccessful_msg" text="default text"/>
${sessionScope["SPRING_SECURITY_LAST_EXCEPTION"].message}</div>
</c:if>
<div class="loginBackground">
<div class="loginFont">Log In</div>
<form name='form1' action="<c:url value='j_spring_security_check' />"
method='POST'>
<label class="fieldStyle"><spring:message code="login.username" text="default text"/></label>
<input class="fieldBox" style="margin-top: 30px; margin-left: 15px;" type='text'
name='j_username' /> <br>
<br> <label class="fieldStyle"><spring:message code="login.password" text="default text"/></label> <input
class="fieldBox" style="margin-left: 25px;" type='password'
name='j_password' /> <br> <input class="loginSubmit"
type="submit" value="Log In" />
</form>
</div>
</body>
</html>