본문 바로가기

Struts2

Strtus2 설정 - struts.xml web.xml 이 파일이 웹 애플리케이션의 배치스크립터(DD) 라는건 다 알고 있는 사실입니다. Struts2가 요청을 받아들일 수 있도록 DD에 필터를 등록해야 합니다. struts org.apache.struts2.dispatcher.FilterDispatcher struts /* struts-default.xml 이 파일의 위치는 프레임워크 코어 라이브러리인 struts2-core-버전.jar 안에 포함되어 있습니다. 즉 사용자가 작성해야 하는 파일이 아니고 미리 정의되어 있는 파일입니다. 그렇다면 왜 이 파일을 여기서 언급 하는 걸까요? 그 이유는 사용자가 작성해야 할 struts.xml 파일의 설정을 상당히 줄일 수 있도록 모든 디폴트 값들이 설정되어 있기 때문입니다. 역시 제로 컨피규레이션 지.. 더보기
스트럿츠2 설치시 에러 스트럿츠2 (Struts2) 를 테스트하고 있었는데 계속 다음과 같은 에러가 나오고 실행이 안되는겁니다. 톰켓을 실행할 때 표시되는 내용: org.apache.catalina.core.StandardContext start 심각: Error filterStart org.apache.catalina.core.StandardContext start 심각: Context [/strutsTest] startup failed due to previous errors localhost.log 파일에는 이런 식으로 표시되죠. org.apache.catalina.core.StandardContext filterStart 심각: Exception starting filter struts2 Unable to load co.. 더보기
스트럿츠2를 사용하여 객체 출력하기 일반 프로퍼티 또는 List 타입의 프로퍼티를 출력하는 방법은 이미 살펴 보았다. 프로퍼티가 아닌 객체 자체를 출력하는 경우는 다음과 같이 할 수 있다. struts.xml /chapter2/printObject.jsp example.model.Product.java package example.model; public class Product { private String name; private String modelNo; public Product() {} public Product(String name, String modelNo) { this.name = name; this.modelNo = modelNo; } public String getName() { return name; } public.. 더보기
스트럿츠2를 사용하여 List 출력하기 이번에는 스트럿츠를 사용하여 List를 출력해 보자. 일단 Action 파일과 result 파일 정의를 struts.xml에 정의하면 다음과 같다. /chapter2/printStringList.jsp 위에서 정의한 대로 PrintStringListAction.java 파일을 example.chapter2 패키지에 만든다. package example.chapter2; import java.util.ArrayList; import java.util.List; public class PrintStringListAction { private List listString; public String execute() throws Exception { listString = new ArrayList(); list.. 더보기