http://static.springframework.org/docs/Spring-MVC-step-by-step/part1.html
web.xml 추가
<servlet>
<servlet-name>springapp</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springapp</servlet-name>
<url-pattern>*.htm</url-pattern> -> *.do로 수정
</servlet-mapping>
2.
C:\spring\util\spring-framework-2.5.5\dist
(1.7 step by step)
spring.jar
spring-webmvc.jar 드레그 해서 이클립스 Webcontent/WEB-INF/lib/에 넣는다.
--------------------
springapp-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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<!-- the application context definition for the springapp DispatcherServlet -->
<bean name="/hello.htm" class="springapp.web.HelloController"/>
</beans>
<bean name="/hello.htm" class="springapp.web.HelloController"/> 요청 Url
<bean id=""> ID 공유할때는 ID ; 특스문자 사용 불가
<!-- http://localhost:8088/spring_1/hello.do -->
<bean name="/hello.do" class="springapp.web.HelloController"/>
=======================================
1. springapp-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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<!-- the application context definition for the springapp DispatcherServlet -->
<!-- http://localhost:8088/spring_1/hello.do -->
<bean name="/hello.do" class="springapp.web.HelloController"/>
//springapp.web.HelloController를 /hello.do로 매핑 합니다.
</beans>
2. HelloController.java class 만들기
package springapp.web;
import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
//import org.apache.commons.logging.Log;
//import org.apache.commons.logging.LogFactory;
import java.io.IOException;
public class HelloController implements Controller {
@Override
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception
{
ModelAndView mv = new ModelAndView();
mv.setViewName("spring_hello.jsp");
mv.addObject("greeting","첫번째 스프링 예제!!!");
return mv;
}
}
3. jsp Page만들기
spring_hello.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!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=EUC-KR">
<title>Insert title here</title>
</head>
<body>
${greeting}
</body>
</html>
4. index.htm
<html>
<head>
<script type="text/javascript">
<!--
location.href="hello.do";
-->
</script>
</head>
<body>
</body>
</html>
----------- 그러면 나온다 ; 아 힘드네 ㅋㅋ