Posted
Filed under JSP, JAVA

한글 처리를 하기 위해서 RequestProcess 를 상속 하여 넘어 오는 모든 Request 에 대해서
UTF-8 인코딩 처리를 하면,
javax.servlet.ServletException: TilesPlugin : Specified RequestProcessor not compatible with TilesRequestProcessor
        at org.apache.struts.tiles.TilesPlugin.initRequestProcessorClass(TilesPlugin.java:360)
        at org.apache.struts.tiles.TilesPlugin.init(TilesPlugin.java:164)
        at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:1158)
        at org.apache.struts.action.ActionServlet.init(ActionServlet.java:473)
        at javax.servlet.GenericServlet.init(GenericServlet.java:258)

와 비슷한 ERROR 메시지가 발생 한다.
API를 찾아 보니 ..

TilesRequestProcessor 라구 Tiles 를 위한 RequestProcessor가 존재 한다.
그럼으로,, TilesRequestProcessor 를 상속 하여 구현 하면 끝..

package com.ubibada.lms.struts;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.RequestProcessor;
import org.apache.struts.tiles.TilesRequestProcessor;

public class DefaultRequestProcessor extends TilesRequestProcessor {
 @Override
 protected boolean processPreprocess(HttpServletRequest request,HttpServletResponse response) {
  try {
   request.setCharacterEncoding("UTF-8");
   return true;
  } catch (Exception e) {
   return false;
  }
 
 }//end function
}

이런식으로
import org.apache.struts.tiles.TilesRequestProcessor;  한 후 상속 하여 구현 하면 된다.
관련 APi
http://struts.apache.org/1.x/struts-tiles/apidocs/org/apache/struts/tiles/TilesRequestProcessor.html

public class TilesRequestProcessor
extends org.apache.struts.action.RequestProcessor

RequestProcessor contains the processing logic that the Struts controller servlet performs as it receives each servlet request from the container.

This processor subclasses the Struts RequestProcessor in order to intercept calls to forward or include. When such calls are done, the Tiles processor checks if the specified URI is a definition name. If true, the definition is retrieved and included. If false, the original URI is included or a forward is performed.

Actually, catching is done by overloading the following methods:  <-- 즉  이거를 상속 해서 구현 하라고 함..


2010/01/19 14:56 2010/01/19 14:56