如何在我的webapp中修复破解的编码? [英] how do i fix broken encoding in my webapp?

查看:273
本文介绍了如何在我的webapp中修复破解的编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在网络应用程序中提交表单时,某些角色(fe德语 umlauts )已损坏当他们进入我的控制器。像üäö这样的字符串就像ÃÃÃöÃÃÃÃö¶¶。。。我如何解决这个问题?

when i submit a form in my web application some characters (f.e. german umlauts) are broken, when they enter my controller. strings like üäö endup like üäö. how do i fix this problem?

我的设置看起来像这样:

my setup looks like this:


  • spring mvc 3.1.2

  • maven 3.0.4或2.2.1(同时尝试)

  • tomcat 7.0.x

  • eclipse(sts 3.1.0)

  • windows 8

  • spring mvc 3.1.2
  • maven 3.0.4 or 2.2.1 (tried both)
  • tomcat 7.0.x
  • eclipse (sts 3.1.0)
  • windows 8

我已经在stackoverflow上找到了,我尝试过以下操作。

based on answers i already found on stackoverflow i have tried following things.

将这些行添加到jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
...
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

pom.xml中的spcified编码:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
...

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <encoding>UTF-8</encoding>
    </configuration>
<plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <configuration>
        <encoding>UTF-8</encoding>
    </configuration>
<plugin>

将eclipse中的编码更改为UTF-8。

同时调查我在以下观察结果中提出的问题。

while investigating the problem i made following observations.


  • 当我右键单击项目中的文件(资源和java文件)并检查指定的编码,它表示UTF-8。

  • 当我输出这些字符在jsps(fe < p>öäü& / p> )它们在浏览器中正确显示。

  • 问题出现在Windows和linux中。

  • when i right-click files in project (resources and java files) and check the specified encoding, it says UTF-8.
  • when i output those characters in jsps(f.e. <p>öäü</p>) they are displayed correctly in the browser.
  • the problem is present in windows and linux.

thx提前为您的答案。

thx in advance for your answers.

更新

通过添加 CharacterEncodingFilter 到我的web.xml

soleved my issue by adding the CharacterEncodingFilter to my web.xml

推荐答案

每当发生关于字符编码的问题时我使用UNICODE r修复它们表达人物。目前我只用韩文和德文字母表。

Every time when issues regarding character encoding occurred I fixed them by using the UNICODE representation of the character. Currently I tried only with Korean and German Alphabet.

这篇关于如何在我的webapp中修复破解的编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆