简体   繁体   English

Tapestry中的表单编码

[英]Form encoding in Tapestry

I have a problem with Tapestry form. 我的挂毯表格有问题。 My XML database is very sensible with encoding, and need utf-8. 我的XML数据库对编码非常敏感,需要utf-8。

When i put the char 'à' in my form, tapestry receive 'Ó' and my core get an error : Invalid byte 2 of 3-byte UTF-8 sequence. 当我将char'à'放入表单中时,挂毯会收到'Ó'并且我的核心得到一个错误:3字节UTF-8序列的无效字节2。

I haven't the problem in eclipse with local default configuration for tomcat. 对于tomcat的本地默认配置,我在Eclipse中没有问题。

But whatever the tomcat configuration, i think my application must do the conversion itself. 但是无论tomcat配置如何,我都认为我的应用程序必须自己进行转换。

So i try : 所以我尝试:

  • charset="utf-8" in form => FAIL charset =“ utf-8”的形式=>失败
  • buildUtf8Filter in AppModule => FAIL AppModule中的buildUtf8Filter =>失败

The charset of every page is always utf-8. 每个页面的字符集始终为utf-8。

So, what could i do before using java Charset encoder ? 那么,在使用Java Charset编码器之前我该怎么办?

thank you for helping me. 感谢你们对我的帮助。 :) :)

I wouldn't think there's anything wrong with your application. 我认为您的应用程序没有任何问题。 Tapestry does everything in UTF-8 by default; Tapestry默认在UTF-8中执行所有操作; that wiki page is fairly out of date (referring to the 5.0.5 beta, where apparently forms with file uploads still didn't use UTF-8 properly). 该Wiki页面已经过时了(指的是5.0.5 Beta,显然带有文件上传的表格仍未正确使用UTF-8)。

You're saying you don't have the problem locally. 您是说您在本地没有问题。 Have you tried running on a different server? 您是否尝试过在其他服务器上运行? If you do not have the problem there, there's probably something wrong with the codepage settings of the operating system on the server. 如果您在那里没有问题,则服务器上操作系统的代码页设置可能存在问题。

Purely anecdotal evidence below 以下纯轶事证据

I have once had a similar character set problem in a Tapestry 5 app on the production server (running SUSE Linux) that I could not reproduce on any other server. 我曾经在生产服务器(运行SUSE Linux)上的Tapestry 5应用程序中遇到过类似的字符集问题,而我无法在任何其他服务器上进行复制。 All seemed fine with the application, the Tomcat server, and the codepage settings of the system, but POST data would end up decoded as ISO 8859-1 instead of UTF-8 in the application. 对于应用程序,Tomcat服务器和系统的代码页设置,一切似乎都很好,但是POST数据最终将解码为ISO 8859-1,而不是应用程序中的UTF-8。 The app had run on that server for a year before the problem manifested - maybe through an update in the operating system. 在出现问题之前,该应用程序已在该服务器上运行了一年-可能是通过操作系统更新来实现的。

Afer a day of not getting anywhere, we ended up just re-installing the whole server OS, and everything was fine again. 经过一天的忙碌之后,我们最终只是重新安装了整个服务器操作系统,然后一切恢复正常。

The problem was about the default charset of the JVM launched into windows shell. 问题是有关Windows shell中启动的JVM的默认字符集。 It caused trouble with FileWriter and then show bad character in the console :) 它导致FileWriter出现问题,然后在控制台中显示错误字符:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM