[Spring4] server.xml 추가세팅, servlet-context.xml 추가세팅

[Spring4] server.xml 추가세팅, servlet-context.xml 추가세팅

1. server.xml 추가세팅

server.xml 의 129라인
<Context docBase=”BBWIKI” path=”/wiki” reloadable=”true” source=”org.eclipse.jst.jee.server:BBWIKI”/></Host>

<Context docBase=”BBWIKI” path=”/” reloadable=”true” source=”org.eclipse.jst.jee.server:BBWIKI”/></Host>
로 변경

=> 이제 http://localhost:8080/wiki 라고 치지 않고, http://localhost:8080/ 라고 치면 value = “/” 로 @RequestMapping 됨

2. servlet-context.xml 추가세팅
servlet-context.xml 의 16라인
<resources mapping=”/resources/**” location=”/resources/” />

<resources mapping=”/css/**” location=”/resources/css/” />
<resources mapping=”/images/**” location=”/resources/images/” />
<resources mapping=”/js/**” location=”/resources/js/” />
<resources mapping=”/resources/**” location=”/resources/” />
로 변경

=> 이제,
http://localhost:8080/resources/js/temp.js 라고 치면 파일시스템상 /src/main/webapp/resources/js/temp.js 파일을 가져옴
또는
http://localhost:8080/js/temp.js 라고 치면 파일시스템상 /src/main/webapp/js/temp.js 파일을 가져옴

3. servlet-context.xml 추가세팅 두번째

servlet-context.xml 의 20라인
<beans:property name=”prefix” value=”/WEB-INF/views/” />
<beans:property name=”suffix” value=”.jsp” />

<beans:property name=”prefix” value=”/WEB-INF/views/” />
<beans:property name=”suffix” value=”” />
로 변경

=> 이제 @Controller 에서 return “home”; 이 아닌 return “home.jsp”; 해야 jsp 파일을 찾아감.

4. 스프링 리스폰스 바디의 한글값이 물음표로 깨질 경우

@ResponseBody
@RequestMapping(value = “/wiki/doc/write_req.do”, method = {RequestMethod.GET, RequestMethod.POST})

@ResponseBody
@RequestMapping(value = “/wiki/doc/write_req.do”, produces=”application/text; charset=UTF8″, method = {RequestMethod.GET, RequestMethod.POST})

로 변경.

단순 문자열이므로 produces=”application/text; charset=UTF8″ 를 추가한 것임.
(json 형태로 내려줄 경우 produces=”application/json; charset=UTF8″ 를 추가해야 함)