WebMVC

ViewBean

package example.u2ware.springfield.part2.step2;

import lombok.Getter;
import lombok.Setter;

import com.u2ware.springfield.config.Springfield;
import com.u2ware.springfield.config.Springfield.Strategy;

@Springfield(
        strategy=Strategy.DTO,
        methodLevelMapping={
                "*","*.do",
                "findForm.json","findForm.xml","findForm.xls",
                "read.json","read.xml","read.xls"
        },
        identity={"code"},
        attributesCSV=
                "webmvc.view.method.findForm={custom}," +
                "webmvc.view.extension.none={jstlView}," +
                "webmvc.view.extension.do={thymeleafView}"
                //"webmvc.view.springfield={springfield3}"
)
public class ViewBean {

        private @Getter @Setter Integer code;
        private @Getter @Setter String name;
}

View Resolver #1

Springfield 의 EntityController 의 각 메소드는 다음과 같은 규칙으로 View Name 을 리턴한다.

/{topLevelMapping}/{methodName}[.{extension}]

HTTPMethod예제 매핑 경로리턴된 view name
... ... ... ... 
... ... ... ... 
GETfindForm/part2/step2"/part2/step2/findForm"
GETfindForm/part2/step2.do"/part2/step2/findForm.do"
GETfindForm/part2/step2.json"/part2/step2/findForm.json"
GETfindForm/part2/step2.xml"/part2/step2/findForm.xml"
GETfindForm/part2/step2.xls"/part2/step2/findForm.xls"
POSTfind/part2/step2"/part2/step2/find"
POSTfind/part2/step2.do"/part2/step2/find.do"
GETread/part2/step2/7"/part2/step2/read"
GETread/part2/step2/7.do"/part2/step2/read.do"
GETread/part2/step2/7.json"/part2/step2/read.json"
GETread/part2/step2/7.xml"/part2/step2/read.xml"
GETread/part2/step2/7.xls"/part2/step2/read.xls"
... ... ... ... 
............

View Resolver #2

Springfield 가 제공하는 각 ViewResolver 들은 먼저, EntityController 로 부터 결정된 View Name 을 설정에 맞게 변경한다.

@Springfield 의 attributesCSV 속성에서 선언된 webmvc.view.method.XXX 값중 해당 View Name 에서 매치하여 변경한다.

HTTPMethod예제 매핑 경로변경된 view name
... ... ... ... 
... ... ... ... 
GETfindForm/part2/step2"/part2/step2/custom"
GETfindForm/part2/step2.do"/part2/step2/custom.do"
GETfindForm/part2/step2.json"/part2/step2/custom.json"
GETfindForm/part2/step2.xml"/part2/step2/custom.xml"
GETfindForm/part2/step2.xls"/part2/step2/custom.xls"
POSTfind/part2/step2"/part2/step2/list"
POSTfind/part2/step2.do"/part2/step2/list.do"
GETread/part2/step2/7"/part2/step2/edit"
GETread/part2/step2/7.do"/part2/step2/edit.do"
GETread/part2/step2/7.json"/part2/step2/edit.json"
GETread/part2/step2/7.xml"/part2/step2/edit.xml"
GETread/part2/step2/7.xls"/part2/step2/edit.xls"
... ... ... ... 
............
application-context.properties:

attributesCSV 에 선언하지 않으면 @Springfield 의 기본설정을 따른다.

webmvc.view.method.home=home
webmvc.view.method.findForm=list
webmvc.view.method.find=list
webmvc.view.method.createForm=edit
webmvc.view.method.create=refresh
webmvc.view.method.read=edit
webmvc.view.method.updateForm=edit
webmvc.view.method.update=refresh
webmvc.view.method.delete=refresh

View Resolver #3

Springfield 가 제공하는 각 ViewResolver 들은 확장자가 일치하면 Rendering 한다.

@Springfield 의 attributesCSV 속성에서 선언된 속성에서 선언된 webmvc.view.extension.XXX 값중 해당 확장자와 매치하여 View Resolver 를 연결한다.

HTTPMethod예제 매핑 경로 결정된 view resolver
... ... ... ... 
... ... ... ... 
GETfindForm/part2/step2jstlView
GETfindForm/part2/step2.dothymeleafView
GETfindForm/part2/step2.jsonjsonView
GETfindForm/part2/step2.xmlxmlView
GETfindForm/part2/step2.xlsxlsView
POSTfind/part2/step2jstlView
POSTfind/part2/step2.dothymeleafView
GETread/part2/step2/7jstlView
GETread/part2/step2/7.dothymeleafView
GETread/part2/step2/7.jsonjsonView
GETread/part2/step2/7.xmlxmlView
GETread/part2/step2/7.xlsxlsView
... ... ... ... 
............
application-context.properties:

attributesCSV 에 선언하지 않으면 @Springfield 의 기본설정을 따른다.

webmvc.view.extension.none=tilesView
webmvc.view.extension.download=downloadView
webmvc.view.extension.stream=streamView
webmvc.view.extension.json=jsonView
webmvc.view.extension.xml=xmlView
webmvc.view.extension.xls=xlsView
webmvc.view.extension.jstl=jstlView
webmvc.view.extension.tiles=tilesView
webmvc.view.extension.thymeleaf=thymeleafView

View Resolver #4

Note:
Springfield 는 여러가지 View Resolver 를 제공한다. 이 중에서 xlsView , jstlView, tilesView, thymeleafView 는 classpath 나 Webapp 경로를 탐색하여 리소스(jsp 나 html 등)의 존재 여부를 Rumtime 에 체크하여 랜더링 여부를 결정한다.

만약, 모든 Resolver 가 모두 랜더링에 실패하면 Springfield 가 제공하는 디폴트 View 화면이 제공된다.