웹 워 크 에서 action result type
5766 단어 jspfreemarkerxmlvelocityWebwork
Webwork1.x ,Webwork2 Action , Result Result Type, Result Type , com.opensymphony.xwork.Result 。Result Type Action ! , Webwork2 Result Type , webwork-default.xml ,xwork.xml , Result Type xwork.xml :
<result-types>
<result-type name="dispatcher" class="com.opensymphony.webwork.dispatcher.ServletDispatcherResult" default="true"/>
<result-type name="redirect" class="com.opensymphony.webwork.dispatcher.ServletRedirectResult"/>
<result-type name="velocity" class="com.opensymphony.webwork.dispatcher.VelocityResult"/>
<result-type name="chain" class="com.opensymphony.xwork.ActionChainResult"/>
<result-type name="xslt" class="com.opensymphony.webwork.views.xslt.XSLTResult"/>
<result-type name="jasper" class="com.opensymphony.webwork.views.jasperreports.JasperReportsResult"/>
<result-type name="freemarker" class="com.opensymphony.webwork.views.freemarker.FreemarkerResult"/>
</result-types>
location parse ,location action ,parse location OGNL 。
1) dispatcher
action , View,Webwork2 RequestDispatcher , Request/Response , Request Atrributes , redirect 。
2) redirect
,redirect Request, Request , requet.getAtrribute set , action ,errors,field errors , Action Single-thread model 。
3) chain
action , View , action action。 actionName, action 。 :
<result name="success" type="chain">
<param name="actionName">bar</param>
<param name="namespace">/foo</param>
</result>
action:
<action name="bar" class="myPackage.barAction">
...
</action>
4) velocity
5) freemarker
6) jasperreports
7) xslt
View。
Result Type , Action testSendmail, email。 Result Type, Result 。
com.mycompany.webwork.example.SendmailResult
:from ,to, subject, body。
xwork.xml :
<result-types>
<result-type name="sendmail" class="com.mycompany.webwork.example.SendmailResult"/>
</result-types>
action :
<action name="testSendmail" class="com.mycompany.webwork.example.TestSendMailAction">
<result name="success" type="sendmail">
<param name="from">[email protected]</param>
<param name="to">[email protected]</param>
<param name="subject">hello,webwork!</param>
</result>
<result name="error" type="dispatcher">
<param name="location">error.jsp</param>
</result>
</action>
SendmailResult.java
package com.opensymphony.webwork.example;
import com.opensymphony.xwork.ActionInvocation;
import com.opensymphony.xwork.Result;
public class SendmailResult implements Result {
private String to;
private String from;
private String subject;
private String body;
public void execute(ActionInvocation invocation) throws Exception {
//TODO Email
System.out.println("sending mail....");
System.out.println(" To:" + to);
System.out.println(" From:" + from);
System.out.println("Subject:" + subject);
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
public String getFrom() {
return from;
}
public void setFrom(String from) {
this.from = from;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String getTo() {
return to;
}
public void setTo(String to) {
this.to = to;
}
}
Action:
package com.opensymphony.webwork.example;
import com.opensymphony.xwork.ActionSupport;
public class TestSendMailAction extends ActionSupport {
public String execute() throws Exception {
return SUCCESS;
}
}
jsp, webwork-example/ :
testsendmail.jsp
<%@ taglib prefix="ww" uri="webwork" %>
<html>
<head><title>Test sendmail restul type</title></head>
<body>
<form action="testSendmail.action">
<input type="Submit" value="Submit"/>
</form>
</body>
</html>
http://localhost:8080/webwork-example/testsendmail.jsp, , :
sending mail....
To:[email protected]
From:[email protected]
Subject:hello,webwork
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
JSP| EL (Experession Language)텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.