1.配置国际化支持
在struts-config.xml文件中加入国际化支持标签,<message-resources parameter="MessageResources" />
注意:此标签需要放在所有标签的最后面
最好将MessageResources.properties文件放在类路径下,如下图所示:

MessageResources的内容如下:
# -- standard errors --
errors.header=
<
UL
>
errors.prefix=
<
LI
>
errors.suffix=
</
LI
>
errors.footer=
</
UL
>
# -- validator --
errors.invalid={0} is invalid.
errors.maxlength={0} can not be greater than {1} characters.
errors.minlength={0} can not be less than {1} characters.
errors.range={0} is not in the range {1} through {2}.
errors.required={0} is required.
errors.byte={0} must be an byte.
errors.date={0} is not a date.
errors.double={0} must be an double.
errors.float={0} must be an float.
errors.integer={0} must be an integer.
errors.long={0} must be an long.
errors.short={0} must be an short.
errors.creditcard={0} is not a valid credit card number.
errors.email={0} is an invalid e-mail address.
# -- other --
errors.cancel=Operation cancelled.
errors.detail={0}
errors.general=The process did not complete. Details should follow.
errors.token=Request could not be completed. Operation is not in sequence.
# -- welcome --
welcome.title=Struts Blank Application
welcome.heading=Welcome!
welcome.message=To get started on your own application, copy the struts-blank.war to a new WAR file using the name for your application. Place it in your container's "webapp" folder (or equivalent), and let your container auto-deploy the application. Edit the skeleton configuration files as needed, restart your container, and you are on your way! (You can find the application.properties file with this message in the /WEB-INF/src/java/resources folder.)
2.使用标签
使用taglib指令引入标签库:
<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %>
<%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic" % >
就可以在jsp中使用标签了
本文介绍如何在 Struts 应用程序中配置和使用国际化功能,包括在 struts-config.xml 中添加国际化支持标签,并在 JSP 页面中引入标签库。
945

被折叠的 条评论
为什么被折叠?



