Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- paint
- HTML
- OGNL
- Android
- 이클립스
- Java
- 메소드
- 클래스
- layout
- JavaScript
- JSP
- AWT
- 국제화
- 메서드
- Menu
- mybatis
- Spring
- 어노테이션
- 안드로이드
- 기본
- 예외처리
- 오버로딩
- Graphic
- 생성자
- Eclips
- struts2
- 배열
- 에러페이지
- oracle
- 전화걸기
Archives
- Today
- Total
note
Spring 예외처리 본문
dispatcher-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
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-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- 예외 처리 -->
<bean class="org.springframwork.web.servlethandler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="java.lang.ArithmeticException">
error/mathException
</prop>
<prop key="java.lang.Exception">
error/exception
</prop>
</props>
</property>
</bean>
<bean class="madvirus.spring.chap06.controller.ArithmeticOperatorController" />
<!-- View 글로벌 설정 -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/view/" />
<property name="suffix" value=".jsp" />
</bean>
<!-- 리소스 번들 지정 -->
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>messages.validation</value>
</list>
</property>
</bean>
</beans>
ArithmeticOperatorController.java
package madvirus.spring.chap06.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
public class ArithmeticOperatorController {
@RequestMapping("/math/divide.do")
public String divide(
@RequestParam("op1") int op1,
@RequestParam("op2") int op2, Model model) {
model.addAttribute("result",op1/op2);
return "math/result";
}
}
math/result.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>연산 성공</title>
</head>
<body>
연산 성공
</body>
</html>
aa
aaa
'JSP > Spring' 카테고리의 다른 글
| LocaleResolver를 이용한 Locale 변경(국제화) (0) | 2012.03.07 |
|---|---|
| Spring 커스텀 태그 / 로그인 유효성 체크 (0) | 2012.03.06 |
| MultipartFile 인터페이스 사용하여 파일업로드,다운로드(자카르타 라이브러리) (0) | 2012.03.06 |
| @PathVariable 을 이용한 주소 확장기능 (0) | 2012.03.06 |
| Spring 요청 URI 매칭 (0) | 2012.03.05 |