Struts and JSP garbled issues considerations

Source: Internet
Author: User

Recently completed a project, which encountered two times more bizarre garbled problem, recorded here, to give himself a wake-up call, but also for the latter to provide reference.

This is a project that is implemented with SSH, in order to prevent garbled, from the database to the page code, and then to struts the default encoding all set to Utf-8 (the specific settings online there are a lot of information, here do not repeat it), thinking that this will be able to have no future, but things have not been so smooth.

1. Submit form using post all the data is normal, and the way to submit the form using get is garbled in Chinese. This is because of the URL encoding problem, the URL of the default encoding is not utf-8, so you need to modify the Server.xml in Tomcat folder to join uriencoding= "UTF-8"

<connector uriencoding= "UTF-8" connectiontimeout= "20000" port= "8080" protocol= "http/1.1" redirectport= "8443"/ >

2. All the data on the page show normal, including Chinese, no garbled. But open source file found as long as the data from the back of the struts tag is garbled, similar to a bunch of numbers. In general, this problem has no effect, after all, the page appears normal, but when displaying the displayed data submitted by the Rich text box, it will print out the label information directly, instead of parsing, if the bold <b> should be shown, the <b>...</b> will be printed directly. At first very confused, later a think, from the background to get the data is normal, why the page will appear this situation, the problem is certainly on the struts label, then a check tag Reference, found <s:property/> There is a property called escape default is True, meaning will skip parsing of HTML, so as long as the set escape= "false" will not have a problem, and then look back at the source file, the content page is normal.

This column more highlights: http://www.bianceng.cn/webkf/JSP/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.