struts中进行国际化的问题
各位大虾:
我第一次做国际化,就碰到一个让我很不开巧的问题,大侠们都帮忙看看。
在做一个简单登录表单的国际化时,我在按钮后面加了两个链接来进行语言的转换,链接到一个DispatchAction进行语言选择。在运行时语言转换基本上正常,就是两个链接的文字在第一次转为中文就不会再转换。
两个链接的代码如下:
<a href="loginAction.do?method=chinese"><bean:message key="href.chinese"/></a>
<a href="loginAction.do?method=english"><bean:message key="href.english"/></a>
action的代码如下:
public class LoginAction extends DispatchAction {
public ActionForward chinese(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
System.out.println("aaaaaaaaa");
request.getSession().setAttribute(Globals.LOCALE_KEY,Locale.CHINA);
return mapping.findForward("succ");
}
//english()方法同上
}
问题点数:20、回复次数:2Top
1 楼xuxiaosz()回复于 2006-12-01 19:21:41 得分 0
把你获得method的那个Action发上来Top
2 楼sxd05()回复于 2006-12-01 19:39:47 得分 0
action就是上面那个呀
public class LoginAction extends DispatchAction {
public ActionForward chinese(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
System.out.println("aaaaaaaaa");
request.getSession().setAttribute(Globals.LOCALE_KEY,Locale.CHINA);
return mapping.findForward("succ");
}
public ActionForward english(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
request.getSession().setAttribute(Globals.LOCALE_KEY,Locale.ENGLISH);
return mapping.findForward("succ");
}
}
struts-config.xml中是这样的:
<struts-config>
<form-beans>
<form-bean name="loginActionForm" type="alldemo.LoginActionForm" />
</form-beans>
<action-mappings>
<action parameter="method" path="/loginAction" scope="request" type="alldemo.LoginAction" validate="false">
<forward name="succ" path="/Login.jsp" />
</action>
<action input="/Login.jsp" name="loginActionForm" path="/userAction" scope="request" type="alldemo.UserAction" validate="true" />
</action-mappings>
<message-resources parameter="ApplicationResources" />
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" />
</plug-in>
</struts-config>
Top





