HelloWorld
struts.xml
web.xml
package tutorial; import com.opensymphony.xwork2.Action; public class HelloWorld implements Action{ private String message; public String getMessage(){ return message; } @Override public String execute() throws Exception { message ="Hello, World"; return SUCCESS; } }
<!--?xml version="1.0" encoding="UTF-8" ?--> <struts> <!-- 1.기본연결 --> <package name="tutorial" extends="struts-default"> <action name="helloWorld" class="tutorial.HelloWorld"> <result name="success">/helloWorld.jsp</result> </action> </package> </struts>
<!--?xml version="1.0" encoding="UTF-8"?--> <web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>struts2Main</display-name> <!-- 스트럿츠는 필터가 서블릿보다 먼저 동작하여 요청을 받는다 --> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> <init-param> <param-name>struts.i18n.encoding</param-name> <param-value>utf-8</param-value> </init-param> </filter> <!-- 모든요청을 필터가 받는다. --> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app>helloWorld.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>테스트</title> </head> <body> ${message} </body> </html>
'Struts2 > 기본(Oracle)' 카테고리의 다른 글
struts2 ActionSupport를 이용한 JSP 호출 (form만 요청할페이지에 사용) (0) | 2012.06.21 |
---|---|
struts2 POJO형태의 액션 만들기 (0) | 2012.06.20 |
struts2 이론 (0) | 2012.06.20 |
struts2 설정 (0) | 2012.06.20 |
struts2 란? (0) | 2012.06.20 |