package com.u2ware.springfield.sample.part4.step2;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import com.u2ware.springfield.config.Springfield;
import com.u2ware.springfield.config.Springfield.Strategy;
@Springfield(
strategy=Strategy.JPA,
methodLevelMapping={
"*","*.do",
"findForm.json","findForm.xml","findForm.xls",
"read.json","read.xml","read.xls"
},
attributesCSV=
"webmvc.view.method.findForm={custom}," +
"webmvc.view.extension.none={jstlView}," +
"webmvc.view.extension.do={jstlView}"
)
@Entity
public @ToString class ViewBean {
@Id
@Getter @Setter private @NotNull String id;
@Getter @Setter private @NotNull String password;
@Getter @Setter private @NotNull String name;
@Getter @Setter private @NotNull Integer age;
}
View Resolver 를 이용한 @Springfield 의 Rendering 은 다음 과정을 거친다.
| HTTP Method | Controller Method 이름 | 예제 매핑 경로 | 1. | 2. | 3. | 4. |
|---|---|---|---|---|---|---|
| ... | ... | ... | ... | ... | ... | ... |
| GET | findForm() | /part4/step2 | "/part4/step2/findForm" | "/part4/step2/custom" | "jstlView" | [baseWebapp]/part4/step2/custom.jsp |
| GET | findForm() | /part4/step2.do | "/part4/step2/findForm.do" | "/part4/step2/custom.do" | "jstlView" | [baseWebapp]/part4/step2/custom.do.jsp |
| GET | findForm() | /part4/step2.json | "/part4/step2/findForm.json" | "/part4/step2/custom.json" | "jsonView" | - |
| GET | findForm() | /part4/step2.xml | "/part4/step2/findForm.xml" | "/part4/step2/custom.xml" | "xmlView" | - |
| GET | findForm() | /part4/step2.xls | "/part4/step2/findForm.xls" | "/part4/step2/custom.xls" | "xlsView" | - |
| ... | ... | ... | ... | ... | ... | ... |
| POST | find() | /part4/step2 | "/part4/step2/find" | "/part4/step2/list" | "jstlView" | [baseWebapp]/part4/step2/list.jsp |
| POST | find() | /part4/step2.do | "/part4/step2/find.do" | "/part4/step2/list.do" | "jstlView" | [baseWebapp]/part4/step2/list.do.jsp |
| ... | ... | ... | ... | ... | ... | ... |
| GET | read() | /part4/step2/7 | "/part4/step2/read" | "/part4/step2/edit" | "jstlView" | [baseWebapp]/part4/step2/edit.jsp |
| GET | read() | /part4/step2/7.do | "/part4/step2/read.do" | "/part4/step2/edit.do" | "jstlView" | [baseWebapp]/part4/step2/edit.do.jsp |
| GET | read() | /part4/step2/7.json | "/part4/step2/read.json" | "/part4/step2/edit.json" | "jsonView" | - |
| GET | read() | /part4/step2/7.xml | "/part4/step2/read.xml" | "/part4/step2/edit.xml" | "xmlView" | - |
| GET | read() | /part4/step2/7.xls | "/part4/step2/read.xls" | "/part4/step2/edit.xls" | "xlsView" | - |
| ... | ... | ... | ... | ... | ... | ... |
Springfield 의 EntityController 의 각 메소드는 다음과 같은 규칙으로 View Name 을 리턴한다.
/{topLevelMapping}/{methodName}[.{extension}]
@Springfield 의 attributesCSV 속성에서 선언된 webmvc.view.method.XXX 값중 해당 View Name 의 메소드와 매치하여 변경한다.
attributesCSV 에 선언하지 않으면 @Springfield 의 기본설정을 따른다.
@Springfield 의 attributesCSV 속성에서 선언된 webmvc.view.extension.XXX 값중 View Name 의 확장자와 매치하여 View Resolver 를 결정한다.
attributesCSV 에 선언하지 않으면 @Springfield 의 기본설정을 따른다.
확장자와 View Resolve 매핑은 추가 및 변경이 가능하다.
만약, 리소스(jsp, html 등)가 필요한 View Resolver 는 Rumtime 에서 View Name 을 기준으로 경로를 탐색하여 리소스의 존재 여부를 확인하고 랜더링 한다.
리소스 탐색의 기준이 되는 경로는 basePackage 와 baseWebapp 이다.