修改struts源码解决ApplicationResources.properties里不能直接用中文的一个方法

修改struts源码解决ApplicationResources.properties里不能直接用中文的一个方法

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

你可能感兴趣的:(修改struts源码解决ApplicationResources.properties里不能直接用中文的一个方法)