관리 메뉴

IT.FARMER

2. 이제 실제 서플릿 파일이라든지 JSP 그리구, xml설정을 해줄거야 본문

JAVA

2. 이제 실제 서플릿 파일이라든지 JSP 그리구, xml설정을 해줄거야

아이티.파머 2010. 8. 23. 11:58
반응형
지금까지는 사용하기 위해서 셋팅 한거구 이제 실제 서플릿 파일이라든지 JSP 그리구,  xml설정을 해줄거야


<액션담당 서블릿 파일>
HelloWorld.java
package action;   
import com.opensymphony.xwork2.Action;   

public
 class HelloWorld implements Action {   
private String message;   
public String getMessage() {   
 
return message;    
}   
 
public String execute() throws Exception {   
  message = 
"Hello, World!";   
 
return SUCCESS;    
}   
}  
 
 
<뷰담당 JSP 파일>
helloWorld.jsp
<html>  
 <head>  

  <title>Hello World</title>  

 </head>  

 <body>  

  message : <h2>${message}</h2>  

 </body>  
</html>

 
 
<struts 매핑 설정>
struts.xml
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"  "http://struts.apache.org/dtds/struts-2.0.dtd">  
<struts>  
 <package name=
"default" extends="struts-default">  
  <action name=
"helloWorld" class="action.HelloWorld">  
  <result name=
"success">/view/helloWorld.jsp</result>  
  </action>  

 </package>

</struts>  
 
<web.xml 설정>
web.xml
<?xml version="1.0" encoding="UTF-8"?>  

<web-app id="WebApp_ID" 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.c/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">   
<display-name>StrutsTest</display-name>  
<welcome-file-list>  
<welcome-file>index.html</welcome-file>  
<welcome-file>index.htm</welcome-file>  
<welcome-file>index.jsp</welcome-file>  
<welcome-file>default.html</welcome-file>  
<welcome-file>default.htm</welcome-file>  
<welcome-file>default.jsp</welcome-file>  
</welcome-file-list>  

<filter>  
<filter-name>struts2</filter-name>  
<filter-class>  
org.apache.struts2.dispatcher.FilterDispatcher  
</filter-class>  
</filter>  

<filter-mapping>  
<filter-name>struts2</filter-name>  
<url-pattern>/*</url-pattern> 
</filter-mapping> 


반응형

'JAVA' 카테고리의 다른 글

JAVA Super Class , Overriding  (0) 2010.09.08
파일 입출력  (0) 2010.08.23
(기타)톰켓 + 다이니믹 웹  (0) 2010.08.23
1. naver API 및 Struts  (0) 2010.08.23
java toString  (0) 2010.05.12