
你的properties中的中文是经过 ascii转码的吗?比如中文变成了这样子: \u8be5\u8d44\u6e90\u7c7b\u578b\u5df2\u7ecf\u5b58\u5728\uff01
如果是,那么只需要将读到的字符串做一下转码即可。
你可以在String username=propertygetProperty("username");之后,添加JAVA代码也可以将乱码转为中文的。用如下语句就可以了,username =new String(usernamegetBytes("ISO-8859-1"),"gbk"); 然后再用resultName就可以了,不过这样的话你下面的String password=propertygetProperty("password");
都慢慢的通过上面的java代码去转。
不知道你对反射熟悉不?如果熟悉的话可以通过反射机制去做转码就方便多了!
<s:if test="#age==23">
23
</s:if>
<s:elseif test="#age==21">
21
</s:elseif>
<s:else>
都不等
</s:else>
public class TestProperties {
public static void main(String[] args) throws FileNotFoundException, IOException {
String s = "要找的字符串";
Properties p = new Properties();
pload(new FileInputStream(new File("c:\\pproperties")));
Iterator itr = pentrySet()iterator();
while (itrhasNext()){
Entry e = (Entry)itrnext();
Systemoutprintln(egetKey() + ": " + egetValue());
if (egetKey()indexOf(s) >= 0 || egetValue()indexOf(s) >= 0) {
Systemoutprintln("有要找的字符串");
}
}
}
}
第一个是开发接口,由你的web应用调用单点登录系统的接口,以获得serverproperty的数据。单点登录系统接口内容为读取property文件,转换为map返回。简单点用>
用eclipse下找不到Property File是需要建立然后保存到对应路径的。
点击new-file
d出如下图所示对话框,选择好文件存放路径和文件名即可,别的文件
以上就是关于java使用property中文乱码全部的内容,包括:java使用property中文乱码、java编程:我用<s:property value="#xxx"/>获取了一个值,可不可以在<c:if>里判断这个值啊,该怎么判断呢、Java如何判断一个properties文件中是否含有指定字符串等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)