jfy3d(剑事)BLOG

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  37 随笔 :: 0 文章 :: 363 评论 :: 0 Trackbacks

native2ascii
用这个命令转换我觉得不方便 不知别人如何 呵呵

改页面8859_1(不能是iso-8859-1)可以不用native2ascii转换ApplicationResources.properties
可是没页都要改啊8859_1也很麻烦

所以只好找struts本身来解决了呵呵

*不过这个方法只适合小应用,不需要多国语言的*

struts.jar

org.apache.struts.taglib.bean.MessageTag类


找到doStartTag()方法

里面有行ResponseUtils.write(super.pageContext, message);

在这行上面加上一句 如下

        try
        {
            message = new String(message.getBytes("iso-8859-1"), "gb2312");
        }
        catch(Exception exception) { }

        ResponseUtils.write(super.pageContext, message);


这样就OK了

<%@ page contentType="text/html; charset=gb2312" language="java" %>
要用gb2312

posted on 2005-05-12 00:21 剑事 阅读(5908) 评论(8)  编辑  收藏 所属分类: struts

评论

# re: 修改struts源码解决ApplicationResources.properties里不能直接用中文的一个方法 2005-05-12 09:18 femto
还行了,习惯了。方正java挺傻的  回复  更多评论
  

# re: 修改struts源码解决ApplicationResources.properties里不能直接用中文的一个方法 2005-12-15 19:18 qq:9557040
这样不利于多国化,本来ApplicationResources.properties就是为了多国语言设计的,这样做反而弄巧成拙了!  回复  更多评论
  

# re: 修改struts源码解决ApplicationResources.properties里不能直接用中文的一个方法 2006-03-02 14:21 天天累
朋友,用你的方法解决了中文显示问题。可是通过formbean里validate方法里出错提示的中文没有办法解决。代码如下:
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
Locale locale = (Locale) request.getLocale();
MessageResources messages = servlet.getResources();
String usernameLabel = messages.getMessage(locale, "label.username");
String passwordLabel = messages.getMessage(locale, "label.password");
if (username == null || username.equals("")) {
errors.add("username", new ActionError("errors.required", usernameLabel));
}

if (password == null || password.equals("")) {
errors.add("password", new ActionError("errors.required", passwordLabel));
}

ApplicationResources.properties文件为:
label.username=用户名
label.password=密码
errors.required={0} 不能为空

提示出来的中文信息都是"?????"请问该怎么解决呢?郁闷中  回复  更多评论
  

# re: 修改struts源码解决ApplicationResources.properties里不能直接用中文的一个方法 2006-03-02 14:41 剑事
如果你用eclipse的话 把ApplicationResources.properties文件编码改成ISO就可以了
不需要我上面的方法

我上面是改的标记库 你这个不通过标记库读 就需要Resources地方修改了
也就是ApplicationResources.properties第一个读取类  回复  更多评论
  

# re: 修改struts源码解决ApplicationResources.properties里不能直接用中文的一个方法 2006-03-02 16:34 天天累
我用的就是eclipse。ISO指的是ISO-8859-1吧。把ApplicationResources.properties改成ISO-88591-1以后还是不行啊,还是乱码!您说的另一种方法改第一读取ApplicationResources.properties类,应该怎么改阿?是改java.util.ResourceBundle这个类吧
  回复  更多评论
  

# re: 修改struts源码解决ApplicationResources.properties里不能直接用中文的一个方法 2006-03-02 20:58 剑事
ResourceBundle对 从这地方读出来后转  回复  更多评论
  

# re: 修改struts源码解决ApplicationResources.properties里不能直接用中文的一个方法 2006-05-19 01:07 蜘蛛
朋友,
没有用Poperties Editor 这个插件吧,
它eclipse,jbuilder插件,可以直接编辑中文,保存就中文件就变成unicode编码了,不是很麻烦的,
不然你自己也可以开发出一个插件解决一下这个问题呀,没有什么大不了的  回复  更多评论
  

# re: 修改struts源码解决ApplicationResources.properties里不能直接用中文的一个方法 2008-07-07 21:21 destimarve
直接用eclipse插件ResourceBundle Editor一切都搞定!  回复  更多评论
  


只有注册用户登录后才能发表评论。


网站导航: