java JBOSS 7 编码未按预期工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10228764/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JBOSS 7 encoding not working as expected
提问by Fofole
I had problems with my listgrids not showing diacritcs corectly and I found out that when I inserted from java into the db the values where already bugged.
我的列表网格没有正确显示变音符号时遇到了问题,我发现当我从 java 插入数据库时,值已经被窃听了。
A post here helped and I changed my project properties -> Text encoding -> other -> UTF-8 and this fixed my problem. Thing is this only fixes my problem locally.
此处的帖子有所帮助,我更改了项目属性 -> 文本编码 -> 其他 -> UTF-8,这解决了我的问题。事情是这只能在本地解决我的问题。
What I need to do is on my Jboss server also set the encoding somehow. This is what I put in my configuration file:
我需要做的是在我的 Jboss 服务器上也以某种方式设置编码。这是我放在我的配置文件中的内容:
<?xml version='1.0' encoding='UTF-8'?>
<server name="vali-ubuntu" xmlns="urn:jboss:domain:1.0">
extensions>
extension module="org.jboss.as.clustering.infinispan"/>
extension module="org.jboss.as.connector"/>
extension module="org.jboss.as.deployment-scanner"/>
extension module="org.jboss.as.ee"/>
extension module="org.jboss.as.ejb3"/>
extension module="org.jboss.as.jaxrs"/>
extension module="org.jboss.as.jmx"/>
extension module="org.jboss.as.logging"/>
extension module="org.jboss.as.naming"/>
extension module="org.jboss.as.osgi"/>
extension module="org.jboss.as.remoting"/>
extension module="org.jboss.as.sar"/>
extension module="org.jboss.as.security"/>
extension module="org.jboss.as.threads"/>
extension module="org.jboss.as.transactions"/>
extension module="org.jboss.as.web"/>
extension module="org.jboss.as.weld"/>
/extensions>
system-properties>
property name="org.apache.catalina.connector.URI_ENCODING" value="UTF-8"/>
property name="org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING" value="tru
e"/>
/system-properties>
//.....
This doesn't work so maybe I need to add something else. I tried everything I could find with no succes so any help is appreciated. Thanks.
这不起作用,所以也许我需要添加其他内容。我尝试了所有我能找到的方法,但没有成功,因此感谢您提供任何帮助。谢谢。
EDIT:From what I read, this will work only in jboss 7.1.0 beta 1 or highier. (URIEncoding) and I use JBoss 7.0.2 so I need a replacement for 7.0.2
编辑:从我读到的,这仅适用于 jboss 7.1.0 beta 1 或更高版本。(URIEncoding) 并且我使用 JBoss 7.0.2 所以我需要替换 7.0.2
回答by vici
for jboss-as-7.1.1.Final i added this line to standalone.conf, this file lives under the directory bin:
对于 jboss-as-7.1.1.Final 我将此行添加到standalone.conf,该文件位于目录bin 下:
JAVA_OPTS="$JAVA_OPTS -Dorg.apache.catalina.connector.URI_ENCODING=UTF-8"
回答by Brian Agnew
Have you tried setting the default encoding for the JVM ? Set the confusingly named property:
您是否尝试过为 JVM 设置默认编码?设置令人困惑的命名属性:
-Dfile.encoding=UTF-8
(for JBoss 5 you'd set this in run.conf. I don't know if this is different for JBoss 7)
(对于 JBoss 5,您可以在 run.conf 中设置它。我不知道 JBoss 7 是否不同)
回答by shasho
For me what solved the problem was adding the following to the components.xml:
对我来说,解决问题的是将以下内容添加到 components.xml:
<web:character-encoding-filter encoding="UTF-8"
override-client="true"
url-pattern="*.seam" />