Struts2 Result 매개 변수 상세 정보
Struts2는 JSP, Free Marker, Velocity 등 다양한 종류의 결과를 지원합니다.
Struts2가 지원하는 다양한 유형의 반환 결과는 다음과 같습니다.
이름.
설명
Chain Result
Action 체인 작업
Dispatcher Result
페이지로 전환하기 위해 일반적으로 JSP 처리
FreeMarker Result
FreeMarker 템플릿 작업
HttpHeader Result
특수한 Http 동작을 제어하는 데 사용
Redirect Result
URL로 리디렉션
Redirect Action Result
Action 으로 리디렉션
Stream Result
일반적으로 파일 다운로드를 처리하는 데 사용되는 InputSream 객체를 브라우저에 보내기
Velocity Result
Velocity 템플릿 작업
XLS Result
XML/XLST 템플릿 작업
PlainText Result
원본 파일 내용(예: 파일 소스 코드) 표시
S2PLUGINS:Tiles Result
Tile 결합 사용
또한 제3자의 Result 유형은 JasperReports Plugin을 포함하여 JasperReport 유형의 보고서 출력을 처리하는 데 전문적으로 사용된다.
struts-default.xml 파일에 이미 모든 종류의 Result에 대한 정의가 있습니다.
<result-types>
<result-type name="chain"
class="com.opensymphony.xwork2.ActionChainResult"/>
<result-type name="dispatcher"
class="org.apache.struts2.dispatcher.ServletDispatcherResult"
default="true"/>
<result-type name="freemarker"
class="org.apache.struts2.views.freemarker.FreemarkerResult"/>
<result-type name="httpheader"
class="org.apache.struts2.dispatcher.HttpHeaderResult"/>
<result-type name="redirect"
class="org.apache.struts2.dispatcher.ServletRedirectResult"/>
<result-type name="redirectAction"
class="org.apache.struts2.dispatcher.ServletActionRedirectResult"/>
<result-type name="stream"
class="org.apache.struts2.dispatcher.StreamResult"/>
<result-type name="velocity"
class="org.apache.struts2.dispatcher.VelocityResult"/>
<result-type name="xslt"
class="org.apache.struts2.views.xslt.XSLTResult"/>
<result-type name="plainText"
class="org.apache.struts2.dispatcher.PlainTextResult" />
<!-- Deprecated name form scheduled for removal in Struts 2.1.0.
The camelCase versions are preferred. See ww-1707 -->
<result-type name="redirect-action"
class="org.apache.struts2.dispatcher.ServletActionRedirectResult"/>
<result-type name="plaintext"
class="org.apache.struts2.dispatcher.PlainTextResult" />
</result-types>
Result 값을 정의합니다.
<result name="success" type="dispatcher">
<param name="location">/ThankYou.jsp</param>
</result>위의 코드는 다음과 같이 요약할 수 있습니다.
<result>
<param name="location">/ThankYou.jsp</param>
</result>
<result>/ThankYou.jsp</result>
<action name="Hello">
<result>/hello/Result.jsp</result>
<result name="error">/hello/Error.jsp</result>
<result name="input">/hello/Input.jsp</result>
</action>
때때로 우리는 전역적인 Result를 정의해야 한다. 이때 우리는 패키지 내부에서 전역적인 Result를 정의할 수 있다. 예를 들어
<global-results>
<result name="error">/Error.jsp</result>
<result name="invalid.token">/Error.jsp</result>
<result name="login" type="redirect-action">Logon!input</result>
</global-results>어떤 때는 Action이 완전하게 실행되었을 때만 어떤 결과를 되돌려야 하는지 알 수 있다. 이때 우리는 Action 내부에서 하나의 속성을 정의할 수 있다. 이 속성은 Action이 완전하게 실행된 후의 Result 값을 저장하는 데 사용된다. 예를 들어
private String nextAction;
public String getNextAction() {
 return nextAction;
}
<action name="fragment" class="FragmentAction">
<result name="next" type="redirect-action">${nextAction}</result>
</action>
다른 액션으로 전달하려면 type=chain을 설정하고 결과는shtml를 추가하지 않습니다
이상은 Struts2 Result 매개 변수에 대한 상세한 설명의 모든 내용입니다. 참고 부탁드리며 많은 응원 부탁드립니다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Struts2 Result 매개 변수 상세 정보서버에 제출하는 처리는 일반적으로 두 단계로 나눌 수 있다. Struts2가 지원하는 다양한 유형의 반환 결과는 다음과 같습니다. Chain Result Action 체인 작업 Dispatcher Result Fre...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.