검색결과 리스트
2007/05/30에 해당되는 글 4건
- 2007.05.30 C++ template 과 java 저너릭스 41
- 2007.05.30 C++ 11장 12장 42
- 2007.05.30 Spring jsp 예외처리 전략 20
- 2007.05.30 나비를 꿈꾸는 그대에게 752
C++ 의 template 구문이 java 5 부터 추가된 저너릭스랑 비슷한 거였구나!
[code]#include <iostream>
using std::endl;
using std::cout;
template <typename T>
class Data
{
T data;
public:
Data(T d){ data=d; }
void SetData(T d){
data=d;
}
T GetData(){
return data;
}
};
int main(void)
{
Data<int> d1(0); // T를 int로 간주하고 객체생성
d1.SetData(10);
Data<char> d2('a'); // T를 char로 간주하고 객체생성
cout << d1.GetData() << endl;
cout << d2.GetData() << endl;
return 0;
}[/code]
C++ 11장 12장 (42) | 2007.05.30 |
---|---|
C++ 과제 (22) | 2007.05.23 |
CPP 10장 (19) | 2007.05.23 |
<< 연산자 오버로딩 하기 (23) | 2007.05.23 |
CPP 9장 (42) | 2007.05.09 |
C++ template 과 java 저너릭스 (41) | 2007.05.30 |
---|---|
C++ 과제 (22) | 2007.05.23 |
CPP 10장 (19) | 2007.05.23 |
<< 연산자 오버로딩 하기 (23) | 2007.05.23 |
CPP 9장 (42) | 2007.05.09 |
Spring 의 bean 부분의 예외를 처리했다고 해도.
기본적으로 jsp 페이지 내에서 발생하는 예외는 spring 만으론 잡을수 없다.
그래서 아래와같은 방법을 썻다.
- web.xml
[code] <error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/WEB-INF/jsp/error.jsp</location>
</error-page>[/code]
- 위와같이 error.jsp 파일을 지정한다.
- error.jsp
[code]<%@page contentType="text/html;chraset=utf-8" isErrorPage="true"%>
<%=exception%>[/code]
- 여기서 중요한건 isErrorPage 속성을 true 로 했다는것이다.
- 이렇게 하면 request 에 "javax.servlet.error.exception" 라는 attribute 가 들어있으면 위와같이 그냥 exception 변수를 쓸수있게 된다.
- BaseExceptionResolver.java
[code]package dic.resolver;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;
public class BaseExceptionResolver implements HandlerExceptionResolver {
private String view = null;
public void setView(String view) {
this.view = view;
}
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object obj, Exception exception) {
exception.printStackTrace();
request.setAttribute("javax.servlet.error.exception",exception);
return new ModelAndView(view);
}
}[/code]
- 위 파일은 예전에 bean 예외를 잡기위해 만들었던 파일인데 저기다가 위와같이 request 에 javax.servlet.error.exception 예외를 추가하면 jsp 의 errorpage 를 그대로 사용할수 있다.
자 이것으로 class 와 page 에서 나는 모든 에러를 한 페이지에서 잡을수 있게 되었다.
Spring 에서 MultiActionController 사용하기 (29) | 2007.06.03 |
---|---|
Spring 에서 properties 파일 다루기. (33) | 2007.06.01 |
Spring 의 exception 처리 전략 (26) | 2007.05.29 |
클래스의 toString 및 equals 메소드 자동으로 만들어주기. (47) | 2007.05.26 |
기본 Controller 지정하기. (23) | 2007.05.24 |
나는 지금 나의 세상밖에 볼수 없으니까. (25) | 2007.08.03 |
---|---|
기원의 기술 (25) | 2007.07.02 |
낯선 것을 거부하지 않는 용기 (41) | 2007.05.03 |
삶에 한 가지를 더 보태라 (646) | 2007.04.17 |
게으름이 인생을 먹어치운다. (42) | 2007.04.10 |
RECENT COMMENT