티스토리 뷰
728x90
프로젝트 생성
test.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <% int sum = 1 + 2; %> 결과 = <%=sum%> </body> </html>
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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="archim" version="3.0"> <display-name>iot</display-name> <session-config> <session-timeout>720</session-timeout> </session-config> <jsp-config> <jsp-property-group> <url-pattern>*.jsp</url-pattern> <page-encoding>UTF-8</page-encoding> </jsp-property-group> <jsp-property-group> <url-pattern>/servlet/*</url-pattern> <page-encoding>UTF-8</page-encoding> </jsp-property-group> </jsp-config> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app>
스프링에서의 POST/GET 한글처리(web.xml)
출처 : Spring MVC : 스프링에서의 POST/GET 한글처리
<filter> <filter-name>characterEncodingFilter</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>characterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
스프링에서의 MVC 설정(web.xml)
출처 : Spring MVC : @MVC와 DispatcherServlet에 대해서
주소 *.iot는 DispatcherServlet이 실행
iot-servlet.xml 찾음
<servlet> <servlet-name>iot</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>iot</servlet-name> <url-pattern>*.iot</url-pattern> </servlet-mapping>
iot-servlet.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:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:security="http://www.springframework.org/schema/security" xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.xsd"> <!-- ========================= JSP View Resolver ========================= --> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean> </beans>
MVC 컨트롤러 package 생성
MVC 컨트롤러 class 생성
package com.iot.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @Controller public class IotController { @RequestMapping(value = "/hello_world.iot", method = RequestMethod.GET) public String hello_world() { return "/hello_world"; } }
MVC 컨트롤러 jsp 생성
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> Hello World </body> </html>
컨트롤더 package 자동으로 스프링 컨테이너 등록(iot-servlet.xml 추가)
<context:component-scan base-package="com.iot.controller"/>
확인
최종 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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="archim" version="3.0"> <display-name>iot</display-name> <!-- 스프링에서의 POST/GET 한글처리(web.xml) --> <filter> <filter-name>characterEncodingFilter</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>characterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- 스프링에서의 MVC 설정(web.xml) --> <servlet> <servlet-name>iot</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>iot</servlet-name> <url-pattern>*.iot</url-pattern> </servlet-mapping> <!-- Session time 설정 --> <session-config> <session-timeout>720</session-timeout> </session-config> <jsp-config> <jsp-property-group> <url-pattern>*.jsp</url-pattern> <page-encoding>UTF-8</page-encoding> </jsp-property-group> <jsp-property-group> <url-pattern>/servlet/*</url-pattern> <page-encoding>UTF-8</page-encoding> </jsp-property-group> </jsp-config> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app>
최종 WebContent\WEB-INF\iot-servlet.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:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:security="http://www.springframework.org/schema/security" xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.xsd"> <!-- 컨트롤더 package 자동으로 스프링 컨테이너 등록 --> <context:component-scan base-package="com.iot.controller"/> <!-- ========================= JSP View Resolver ========================= --> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean> </beans>
댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- JavaScript
- 일본여행
- android
- 레이싱모델 익스트림 포토 페스티벌
- Delphi
- Delphi Tip
- 송주경
- Java
- ffmpeg
- 전예희
- Spring
- 튜닝쇼 2008
- Xcode
- 지스타2007
- KOBA
- MySQL
- koba2010
- Mac
- NDK
- Spring MVC
- SAS
- 서울오토살롱
- Linux
- ubuntu
- sas2009
- ble
- 동경
- oracle
- flex
- BPI-M4
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함