web.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_3_0.xsd” id=”WebApp_ID” version=”3.0″>
  <display-name>SpringWebProject2</display-name>

  <servlet>
   <servlet-name>mvc</servlet-name>
   <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
   <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/config/app.xml</param-value>
   </init-param>
  </servlet>
  <servlet-mapping>
   <servlet-name>mvc</servlet-name>
   <url-pattern>*.do</url-pattern>
  </servlet-mapping>

  <!– 한글 변환 코드 –>
  <filter>
   <filter-name>e</filter-name>
   <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
   <init-param>
    <param-name>encoding</param-name>
    <param-value>EUC-KR</param-value>
   </init-param>
   
  </filter>
  <filter-mapping>
   <filter-name>e</filter-name>
   <url-pattern>/*</url-pattern>
  </filter-mapping>

  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>

———————————————————————

컨트롤러 등록
   =DI (XML, 애너테이션 등록)
   =MVC 구조
      =ORM
   =공통모듈(AOP)
      -보안
      -트랜잭션
   =Tiles, OXM, Spring-data
  
<param-value>/WEB-INF/config/app.xml</param-value> 은
/WEB-INF/config/app*.xml 을 쓰거나
/WEB-INF/config/one.xml,/WEB-INF/config/two.xml 식으로 쓸 수 있음
   

    public class DispatcherServlet extends HttpServlet
    {
        WebApplicationContext wc;
     public void init(StringConfig config){
        String path=config.getInitParameter(“contextConfigLocation”);
        if(path==null)
          path=”/WEB-INF/”+<servlet-name>+”-servlet.xml”; (서블릿네임이 spring일 경우 spring-servlet.xml이 될 수 있음)
        wc=new WebApplicationContext(path);
     }
     doGet, doPost
     public void doProcess(){
         Model model=()
     }
     
   }

   매개변수로 Request가 더 이상 넘어오지 않음. (HttpSession 과 매개변수를 써야함)
    @RequestMapping(“a.do”)
    //a.do?name=홍길동&page=1& …
    public String a(String name,int page,MemberVO vo,HttpSession session){
     return “folder/filename”;
    }

  <!– 에러코드 –>
<error-page>
   <error-code>404</error-code>
   <location>/error/error404.jsp</location>
</error-page>
  
분석 순서 : web.xml
            DispatcherServlet : Spring
               /WEB-INF/applicationContext.xml
            FilterDispatcher : struts2
               /SRC/struts.xml
            ActionServlet : struts
               /SRC/struts-config.xml–>