sitelink1 | |
---|---|
sitelink2 | |
extra_vars5 | |
extra_vars6 |
Welcome Page
A web application, like any other web site, can specify a list of welcome pages. When you open a web application without specifying a particular page, a default "welcome page" is served as the response.
다른 웹사이트와 마찬가지로 웰컴 페이지의 리스트를 명시할 수 있다. 웹사이트를 열었을때 특정한 페이지를 지정하지 않는다면 기본적으로 "welcome page"가 서비스 된다.
web.xml
When a web application loads, the container reads and parses the "Web Application Deployment Descriptor", or "web.xml" file. The framework plugs into a web application via a servlet filter. Like any filter, the "struts2" filter is deployed via the "web.xml".
웹 어플리케이션이 로드될때 컨테이너는 "Web Application Deployment Descriptor" 또는 "web.xml" 파일을 읽고 파싱한다. 프레임워크는 servlet filter를 경유하여 웹 어플리케이션에 결합된다. "struts2" fitler는 "web.xml"에 경유하여 디플로이 된다.
web.xml - The Web Application Deployment Descriptor
·미리보기 | 소스복사·- <?xml version="1.0" encoding="ISO-8859-1"?>
- <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd">
- <web-app>
-
- <display-name>Struts 2 MailReader</display-name>
-
- <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>
-
- <listener>
- <listener-class>
- org.springframework.web.context.ContextLoaderListener
- </listener-class>
- </listener>
-
- <!-- Application Listener for MailReader database -->
- <listener>
- <listener-class>
- mailreader2.ApplicationListener
- </listener-class>
- </listener>
-
- <welcome-file-list>
- <welcome-file>index.html</welcome-file>
- </welcome-file-list>
-
- </web-app>
- <?xml version="1.0" encoding="ISO-8859-1"?>
- <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd">
- <web-app>
- <display-name>Struts 2 MailReader</display-name>
- <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>
- <listener>
- <listener-class>
- org.springframework.web.context.ContextLoaderListener
- </listener-class>
- </listener>
- <!-- Application Listener for MailReader database -->
- <listener>
- <listener-class>
- mailreader2.ApplicationListener
- </listener-class>
- </listener>
- <welcome-file-list>
- <welcome-file>index.html</welcome-file>
- </welcome-file-list>
- </web-app>
You might note that the web.xml configuration does not specify which file extension to use with actions. The default extension for Struts 2 is ".action", but the extension can be changed in the struts.properties file. For compatability with prior releases, the MailReader uses a .do extension for actions.
당신이 web.xml에 환경설정하는 것이 action 사용을 위한 화일 확장을 의미하지는 않는다.
struts2의 기본 확장은 ".action"이지만 확장이 struts.properties 화일내에서 변경될 수 있다.
이전 릴리즈와의 호환성을 위해 MailReader는 액션의 확장으로 .do를 사용한다.
struts.properties
struts.action.extension = do
The web.xml does specify a "Welcome File List" for the application. When a web address refers to a directory rather than an individual file, the container consults the Welcome File List for the name of a page to open by default.
However, most Struts applications do not refer to physical pages, but to "virtual resources" called actions. Actions specify code that we want to be run before a page or other resource renders the response. An accepted practice is to never link directly to server pages, but only to logical action mappings. By linking to actions, developers can often "rewire" an application without editing the server pages.
web.xml 화일에 어플리케이션에 대한 "Welcome File List"을 명시한다.
web address는 개별적인 file이라기보다는 directory로 연결된다. 컨테이너는 기본 open으로 page의 이름에 대한 Welcome File List를 참고한다.
그러나 대부분의 struts 어플리케이션은 물리적인 page에 연결되지 않고, "virtual resources" 라 불리는 액션에 연결된다.
Action은 이전 페이지 또는 응답에 대한 다른 resource를 실행하기를 원하는 코드를 명시한다.
실제로는 server page에 직접적으로 link하지 않고, 단지 logical action mapping을 하게 된다.
action의 link에 의해 개발자는 server page의 수정없이 어플리케이션의 "rewire"(비즈니스 로직의 변경)를 수행할 수 있다.
Best Practice:
"Link actions not pages."