티스토리 뷰
를 참조 하였다.
- 다이나믹 웹 프로젝트 생성
- 바로 완료하지 말고
- src폴더 지우기
- content directory를 webapp으로 바꾸기
- Configure로 메이븐 선택
- 소스 파일 생성
- src.main.java
- src.main.resources
- src.test.java
- src.test.resources
- 프로젝트에 resources파일 추가하기
- Propertice > Java Build Path > Source
- Add Folder 로 위에 생성한 폴더 전부 추가
- web.xml 수정
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | <?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <!-- DispathcherSerlvet 설정 --> <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/applicationContext.xml </param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <!-- 필터 설정 --> <filter> <filter-name>encodingFilter</filter-name> <filter-class> org.springframework.web.filter.CharacterEncodingFilter </filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app> | cs |
맨처음 web.xml
1 2 3 4 5 6 7 8 9 10 11 12 | <?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>star</display-name> <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> | cs |
- pom.xml 에 추가
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>star</groupId> <artifactId>star</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> <encoding>${project.build.sourceEncoding}</encoding> </configuration> </plugin> <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <warSourceDirectory>webapp</warSourceDirectory> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>3.2.9.RELEASE</version> </dependency> </dependencies> </project> | cs |
- 메이븐 프로젝트 업데이트
- pom.xml > Dependencies > Add 로
- spring을 검색해서 org.springframework.spring-web mvc를 선택하고 ok!
- 그리고 메이븐 > 프로젝트 업데이트
- applicationContext.xml 파일 설정
- WEB-INF 폴더 밑에 applicationContext.xml 파일 생성 후 아래 내용을 붙여넣는다.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
<mvc:annotation-driven/>
<context:component-scan base-package="com.test.web" />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/view" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
- jsp 파일 생성.
- applicationContext.xml에서 설정한 것처럼
/WEB-INF/view 밑에 JSP파일을 만들면 된다.
- applicationContext.xml에서 설정한 것처럼
- 기본 패키지 생성
- applicationContext.xml 의 <context:component-scan base-package="com.test.web" />
- 처럼 패키지를 설정해주면 된다. 변경이 된다면 변경된 패키지에 맞게 설정해주면 된다.
'spring 스프링' 카테고리의 다른 글
log4j 2 설정 (0) | 2017.07.22 |
---|---|
Log4j 개념 (0) | 2017.07.22 |
DAO (0) | 2017.07.22 |
데이터베이스 경로 수정 (0) | 2017.07.22 |
소스 역추적 하기..... (0) | 2017.07.22 |
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 톰캣
- Lalavel
- input
- Apach
- 최고심
- 위잇딜라이트
- 힘냉면록
- Oracle
- 맥
- SQL
- tree로만들기
- 조직도관리
- Tomcat
- 성수밥
- Mac
- server.xml
- node관리
- Eclipse
- 오라클
- 성수뚝떡
- 르프리크
- 아파치
- 토라식당
- 터미널
- jstree
- 정규식
- floating button
- 이클립스
- 메뉴관리
- html
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함