2.3 Your first action
2.3.1 Saying hello, the WebWork way
package com.oracleclub.study.xwork;
import com.opensymphony.xwork.Action;
public class HelloWorld implements Action {
private String message;
public String execute() {
message = "Hello, World!\n";
message += "The time is:\n";
message += System.currentTimeMillis();
return SUCCESS;
}
public String getMessage() {
return message;
}
}
2.3.2 Displaying output to the web browser
<%@ taglib prefix="ww" uri="webwork" %>
<html>
<head>
<title>Hello Page</title>
</head>
<body>
The message generated by my first action is:
<ww:property value="message"/>
</body>
</html>
2.3.3 Configuring your new action
- xwork.xml 설정
- xwork.xml에 설정을 하지 않고 webwork-study.xml 설정파일을 추가로 만들어서 webwork환경 설정을 하였다.
<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN"
"http://www.opensymphony.com/xwork/xwork-1.0.dtd">
<xwork>
<include file="/resources/webwork/webwork-default.xml"/>
<!-- webwork-study.xml 에 설정 하였음 -->
<include file="/resources/webwork/webwork-study.xml"/>
</xwork>
<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.1.1//EN" "http://www.opensymphony.com/xwork/xwork-1.1.1.dtd">
<xwork>
<package name="study" extends="webwork-default">
<action name="helloWorld" class="com.oracleclub.study.xwork.HelloWorld">
<result name="success">/xwork/hello.jsp</result>
</action>
</package>
</xwork>
문서에 대하여