国际化

您所在的位置:网站首页 springmvc支持路径中的占位符 国际化

国际化

2023-04-30 19:32| 来源: 网络整理| 查看: 265

知识点: 【

第三步:编写页面index.jsp文件

My JSP 'index.jsp' starting page liyong come here !

第四步:这里为了在Action中访问资源文件编写action 名称:globalResourceAction

public class globalResourceAction extends ActionSupport{ private String message; public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } @Override public String execute() throws Exception { //下面获得的资源中第二个参数是占位符中对应的值 message=this.getText("welcome",new String[]{"liyong","come here!"}); return "message"; } }

第五步:编写一个返回视图 messag.jsp

My JSP 'message.jsp' starting page ${message }

第六步:部署

访问页面:http://localhost:080/Native/index.jsp 访问action:http://localhost8080/Native/test/golbalResource

注意:改变浏览器的语言设置环境可以看到在不同的语言环境中出现不同语言内容:welcome={0} welcome {1}、welcome={0} \u6B22\u8FCE {1} 注意:这是myeclipse7.1会自动转换为unicode 见知识点。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3