반응형
web.xml
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<!-- <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value> -->
<!-- servlet-context xml 파일 변경강-->
<param-value>/WEB-INF/config/spring-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
나는 servlet-context 파일을
WEB-INF 폴더아래 config 폴더를 만들고 sping-config.xml 로 변경해줬다
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<!-- /images로 요청하면 /WEB-INF/static/images/위치에서 찾겠다는 의미 -->
<resources mapping="/images/**" location="/WEB-INF/static/images/" />
<img src="/springmvc/images/bts.jpg" width="300" alt="" />
<!-- css / js 도 설정 추가 -->
<resources mapping="/common/css/**" location="/WEB-INF/static/common/css/" />
<resources mapping="/common/js/**" location="/WEB-INF/static/common/js/" />
InternalResourceViewResolver
- prefix 접두사
- suffix 접미사
prefix + [mapping return 값] + suffix
<!-- Spring Container start 될 때 base package에
명시된 패키지를 읽어서 컨트롤러를 객체로 생성해서 소유 -->
<context:component-scan base-package="com.mutli.springmvc" />
<context:component-scan base-package="main" />
<context:component-scan base-package="test" />
base-package 값 아래 모든걸 scan
728x90
반응형
'Web > Spring' 카테고리의 다른 글
Spring boot application.properties 세팅 (JSP / Thymeleaf 둘다 사용) (0) | 2023.05.30 |
---|---|
Spring boot를 위한 STS4 Maven 세팅(설치부터) (2) | 2023.05.30 |
Spring tiles 사용 (2) | 2023.05.10 |
Spring JDBC 환경 설정 (MySQL) (0) | 2023.05.09 |
MVN repository (1) | 2023.05.08 |