728x90
pom.xml 설정 (jstl 라이브러리 추가)
더보기
<!-- jstl -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
pom.xml 설정 (jdbc 라이브러리 추가)
더보기
<!-- Oracle JDBC -->
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.4</version>
</dependency>
web.xml 설정(Context Listener 등록)
더보기
<!-- Context Listener 등록 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
applicationContext 파일 만들기
applicationContext.xml 파일 생성 후 코드 작성
더보기
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.1.xsd
http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring
http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.1.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.0.xsd">
<context:annotation-config />
<context:component-scan base-package="com.javaex">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Repository" />
<context:include-filter type="annotation" expression="org.springframework.stereotype.Service" />
<context:include-filter type="annotation" expression="org.springframework.stereotype.Component" />
</context:component-scan>
</beans>
html, css, js, img 파일 접근 처리
html, css, js, img 파일 접근시 발생하는 오류 이유
DefaultServlet이 핸들러를 찾을 수 없기 때문
매핑 정보 중, 스프링이 처리할 수 없는 요청은 서블릿 컨테이터가 제공하는 디폴트 서블릿에게 위임.
(servlet.xml에 코드 추가)
더보기
<!-- 서블릿 컨테이너의 디폴트 서블릿 위임 핸들러 -->
<mvc:default-servlet-handler />
<mvc:annotation-driven />
View Resolver 설정
spring-servlet.xml
더보기
<!-- 기본 뷰 리졸버 -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
<property name="order" value="1" />
</bean>
반응형
'Server > Spring&Spring Boot' 카테고리의 다른 글
[Spring] 스프링, 마이 바티스(MyBatis) 세팅 정리 (0) | 2022.06.17 |
---|---|
[Tomcat 8.5] 새 워크 스페이스, 프로젝트 Server add가 안되는 현상 (0) | 2022.06.14 |
[Spring] @Autowired 활용 (0) | 2022.06.14 |
스프링(Spring) 셋팅 1 (0) | 2022.06.10 |
Spring 첫 걸음 (0) | 2022.06.10 |