Solve the Problem of passing garbled values to actions by JSP

Source: Internet
Author: User

<HTML: checkbox> is used to upload values to the action when you select the drop-down menu. How can this happen? After thinking for a long time, the results are searched on Google; they all say that the encoding method is not converted. At this time, I am very happy. I saved it, so I made up a class. As follows:

Package com. xicai. util;

 

Import java. Io. unsupportedencodingexception;

Import javax. servlet. http. httpservletrequest;
Import javax. servlet. http. httpservletresponse;

Import org. Apache. Struts. Action. requestprocessor;

Public class myrequestprocessor extends requestprocessor {
Protected Boolean processpreprocess (httpservletrequest request, httpservletresponse response ){
Try {
Request. setcharacterencoding ("gb2312 ");
} Catch (unsupportedencodingexception e ){
// Todo auto-generated Catch Block
E. printstacktrace ();
}
Return super. processpreprocess (request, response );
}
}

Be careful to deploy one side in myeclipse. After opening the URL result, when I select checkbox, the values in the action are still the same, "garbled ". Speechless! No way. You have to check whether there are any tricks on the Internet! Suddenly, I rushed into MM's blog. Hey! She has an article above to introduce strut's principles. After I carefully read her photo, I am still waiting for a long time. So let's look at the article. Hard work! As mentioned above, adding other Java classes requires adding a node to the struts-config.xml. I immediately ran to my project and added a node.

<Controller processorclass = "com. xicai. util. myrequestprocessor"> </controller> I deployed it again with curiosity! OK.

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.