strust2 노트

15100 단어 struts2
struts.xml 파일은 여러 xml 파일에 분리해서 쓸 수 있습니다.마지막으로 다음을 통해struts로 가져옵니다.xml에서 다음을 수행할 수 있습니다.
<struts><includefile="my-struts1.xml"/><includefile="my-struts2.xml"/></struts>

struts.properties file
먼저struts.properties 파일은 웹-info/classess 파일에 넣어야 합니다. 이 파일에 대한 설정은 실제로struts2-core-x.y.z.jar에 있는default를 다시 썼습니다.properties 파일
 
AcionSupport 클래스는 다음과 같은 Action 인터페이스를 구현합니다.
publicinterfaceAction{publicstaticfinalString SUCCESS ="success";publicstaticfinalString NONE ="none";publicstaticfinalString ERROR ="error";publicstaticfinalString INPUT ="input";publicstaticfinalString LOGIN ="login";publicString execute()throwsException;}
         execu  return       success  Action     SUCCESS 


Interceptors(   )
   action     struts2      ,  :

SN Interceptor & Description
1
aliasAllows parameters to have different name aliases across requests.
2
checkboxAssists in managing check boxes by adding a parameter value of false for check boxes that are not checked.
3
conversionErrorPlaces error information from converting strings to parameter types into the action's field errors.
4
createSessionAutomatically creates an HTTP session if one does not already exist.
5
debuggingProvides several different debugging screens to the developer.
6
execAndWaitSends the user to an intermediary waiting page while the action executes in the background.
7
exceptionMaps exceptions that are thrown from an action to a result, allowing automatic exception handling via redirection.
8
fileUploadFacilitates easy file uploading.
9
i18nKeeps track of the selected locale during a user's session.
10
loggerProvides simple logging by outputting the name of the action being executed.
11
paramsSets the request parameters on the action.
12
prepareThis is typically used to do pre-processing work, such as setup database connections.
13
profileAllows simple profiling information to be logged for actions.
14
scopeStores and retrieves the action's state in the session or application scope.
15
ServletConfigProvides the action with access to various servlet-based information.
16
timerProvides simple profiling information in the form of how long the action takes to execute.
17
tokenChecks the action for a valid token to prevent duplicate formsubmission.
18
validationProvides validation support for actions  

         ,          Inerceptor  ,  :
publicinterfaceInterceptorextendsSerializable{void destroy();void init();String intercept(ActionInvocation invocation)throwsException;
       init destory   
AbstractInterceptor  
              , struts.xml  package     inteceptor         
<struts><constantname="struts.devMode"value="true"/><packagename="helloworld"extends="struts-default"><interceptors><interceptorname="myinterceptor"class="com.tutorialspoint.struts2.MyInterceptor"/></interceptors><actionname="hello"class="com.tutorialspoint.struts2.HelloWorldAction"method="execute"><interceptor-refname="params"/><interceptor-refname="myinterceptor"/><resultname="success">/HelloWorld.jsp</result></action></package></struts>

좋은 웹페이지 즐겨찾기