2014-10-13 Struts2

jsp2.0 2014. 10. 13. 09:52





Java Resources -> src -> struts.xml생성


web.xml 파일

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">

<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>

</web-app>


상수

public static final String SUCCESS = "success";  기본값

public static final String NONE = "none";     정상처리 되었지만 view 필요 없을 때

public static final String ERROR = "error";

public static final String INPUT = "input";     파라미터가 못 왔을 때 

public static final String LOGIN = "login";    로그인 실패 했을 때 




struts.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="" extends="">
<action name="" class="">
<result></result>
</action>
</package>

</struts>
추가

    


실행방법

http://localhost:8000/struts/hello.aciton

프로젝트 이름/ 액션 테그 이름


pojo방식

aaa.java 

execute가 기본 메서드

메서드 이름 변경 후 

struts.xml파일에 

<action name="test" class="struts.hello.TestAction"> 에 메서드 이름 추가하면 메서드 사용 가능

method="abcd"





Validateable 유효성 검사




1.set 먼저 동작

2.Validateable - set메서드에 들어온 값을 확인

3. execute



Struts =>기본 설정이 되어있다.


request.getParamater ==> setXXXX

request.setAttribute ==> getXXX


'jsp2.0' 카테고리의 다른 글

2014-10-15 인터셉터  (0) 2014.10.15
2014-10-14 인터셉터  (0) 2014.10.14
2014-10-08  (0) 2014.10.08
2014-10-07  (0) 2014.10.07
10-01 슈퍼인터페이스  (0) 2014.10.01
Posted by 5DMK2]발자국
,