Solving method of Actionform Chinese garbled problem in JSP

Source: Internet
Author: User

Let's get to know Actionform.

Actionform concept

The actionform is used to encapsulate the user's request parameters, and the request parameters are passed through the form field of the JSP page. Therefore, the Actionform parameter should be guaranteed to be the same as the name of the form field. Treatment of psoriasis www.0412l.com with Anshan

Edit this paragraph actionform configuration

All Actionform are configured in the Struts-config.xm L file, which includes a Form-beans element that defines all the actionform, each actionform corresponding to a form-bean element.

When the JSP page receives the Actionform property, if the input is Chinese, then the actionform will be garbled after receiving it.

The solution has 2:

In the action class, this I tried, not feasible.

In Actionform, this I tried, it worked, and it was convenient.

Add the following code to the Reset method in Actionform to output English or Chinese

View Sourceprint?

public void Reset (actionmapping mapping, HTTPS tutorial Ervletrequest request) {

try {

Request.setcharacterencoding ("GBK");

} catch (Exception e) {

Todo:handle exception

}

}

Then the action can output the properties of the Chinese. Anshan Treatment Psoriasis Hospital www.0412l.com

View Sourceprint?

Public Actionforward Execute (actionmapping mapping, Actionform form,

HttpServletRequest request, HttpServletResponse response) {

Personalform personalform = (personalform) form;//Todo auto-generated method stub

System.out.println (Personalform.getusername ());

System.out.println (Personalform.getpassword ());

Return Mapping.findforward ("Step2");

}

Solving method of Actionform Chinese garbled problem in JSP

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.