---
title: "（7）扩展RequestProcessor类"
author: "bolan392"
date: "2009-07-09T17:02:10Z"
tags: []
slug: "7-requestprocessor"
draft: false
lastmod: "2009-07-09T17:02:10Z"
id: 422742
url: "https://bolan392.iteye.com/blog/422742"
---

1.         创建一个类继承RequestProcessor并且重写process()方法

public class MyRequestProcessor extends RequestProcessor {

 @Override  
 public void process(HttpServletRequest arg0, HttpServletResponse arg1)  
   throws IOException, ServletException {  
  System.out.println("调用Action之前的工作在这里完成");  
  super.process(arg0, arg1);  
 }  
}

2\. 在struts-config.xml文件中配置自定义的RequestProcessor类

&lt;controller processorClass="com.rhcj.struts.MyRequestProcessor"  
       locale="true"  
       nocache="true"  
       contentType="text/html;charset=gbk"&gt;     

&lt;/controller&gt;