Processing requests with the Requestprocessor class

Source: Internet
Author: User

Java EE Development of various types of resources download list, the history of the most complete IT resources, personal collection summary.


The <controller> tags are configured primarily to allow struts to identify the controller components that are customized by the developer. Enable them to process requests using different requestprocessor classes.

<controller processorclass= "Edu.encoding.RequestChinese" ></controller>

Processorclass: Specifies the full classpath name of the requested Java class. Default is Org.apache.struts.action.RequestProcessor.

user-defined Requestprocessor class

(1) A class written by the user must inherit the Requestprocessor class and override its process () method.

(2) The function of this class and actionservlet is to process the controller component of the request, which is called by the Actionservlet to process the request. A request that is processed before entering actionform and action.

public class Requestchinese extends Requestprocessor {

@Override

public void process (HttpServletRequest request, httpservletresponse response)

Throws IOException, Servletexception {

Request.setcharacterencoding ("Utf-8");

The next sentence is to be executed, which means to give the request to the controller below.

Super.process (request, response);

}

}

Mappings in Struts-config.xml:

<controller processorclass= "Edu.encoding.RequestChinese" ></controller>

Or:

<controller>

<set-property property= "Processorclass" value= "Org.springframework.web.struts.DelegatingRequestProcessor"/ >

</controller>

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.