'전체'에 해당되는 글 24건
- 2012/01/27 심볼릭 링크만 찾기
- 2011/03/09 "알 수 없는 오류가 발생하였습니다." 라는 에러 메시지가 발생했을 때 대처법 (1)
- 2010/08/16 전자정부프레임워크 사용 중 중복 저장 방지 (새로고침 혹은 뒤로가기시) (1)
- 2010/06/15 THE BUCKET LIST (1)
- 2010/04/21 자바에서 착각하기 쉬운 것들
- 2010/04/21 Tiles2에서 패러미터 전송을 통한 페이지 뷰
- 2010/04/19 Dynamic Tiles2 Maven Repository
- 2010/04/12 유니코드 properties 파일을 한글로 보는 이클립스 플러그인
- 2010/04/08 [에러] lelvel numver 20 is not recognized.
- 2010/04/06 전자정부 프레임워크 공통 컴포넌트로 톰캣 구동시 에러 (1)
작년에 수행했던 전자정부 프레임워크에서는 에러메시지는 비교적 예쁘게 발생하는 편이라 에러잡는데 크게 어려움을 못 느꼈었다.
올해 프로젝트를 하고 있는 중에 "알 수 없는 오류가 발생하였습니다."라는 메시지가 나타나면서 서버도, 사용자도, 프레임워크도 정말 알 수 없는 오류가 되어버렸다.
log4j의 debug레벨 출력에도, Was의 로그에도 그 어디에도 에러의 흔적이 나타나지 않았다.
당황해하면서도... intellij의 디버깅 모드로 잡아서 처리하거나 디버깅도 안잡히면 정말 감으로 때려잡는(!) 기가막힌 상황이 발생하였다. (감으로 때려잡는 승률이 꽤 괜찮아서 이젠 나도 점점 급수가 오르는 느낌이다.)
그러던 중~ 오늘 작년에 진행하던 프로젝트의 유지보수 작업을 하였는데 이게 알 수 없는 에러를 뿌려댐과 동시에, 디버깅에도 잡히지 않았고 감에도 잡히지 않았다. (ㅠ_ㅡ)
이틀간의 삽질 끝에 에러를 못 잡다가 에러 페이지의 하단 공백이 새삼 안쓰러워서(?!)
/WEB-INF/jsp/egovframework/cmm/egovError.jsp
파일을 열어봤더니...
세상에... 에러메시지를 출력하는 구문이 주석처리가 되어있었던 것이다!
원래 분명히 있었으나 저번에 웹취약성 감사를 받으면서 주석처리 해버렸는데 까맣게 잊고 있었던 것이었다.
그렇다면 현재 진행하고 있는 놈은?! 하는 생각에 봤더니... 국정원에서 친절하게 가이드 해주셔서 아예 배포본부터 빼놓은 듯 하다.
빼놨으면 고지를 해주던가!!!!!!!!!!!!!!!!!!!
아 진짜 나라밥 먹는 것들은 왜 하나같이 업무 태만으로 국민을 고생시키는걸까...ㅠ_ㅡ
알 수 없는 오류 때문에 고생하시는 개발자 분들 아래 파일에 다음과 같은 라인을 추가해주면 에러가 예쁘게 나타난다.
egovError.jsp
dataAccessFailure.jsp
egovBizException.jsp
추가 구문 - 서버 콘솔 로깅
Throwable ex = (Throwable)request.getAttribute("exception");
ex.printStackTrace();
%>
화면에 직접 에러를 보이고 싶을 때
쉽다.
이젠 고생 그만해야지.. ㅠ_ㅡ
public String updateCvplCnsltBest(
CvplCnsltVO cvplCnsltVO,
@ModelAttribute("searchVO") CvplSearchVO searchVO, SessionStatus status)
throws Exception {
if(egovWebServiceClientRegisterCvpl.registerCvpl(cvplCnsltVO)) {
cvplCnsltService.updateCvplCnsltBest(cvplCnsltVO);
status.setComplete();
}
return "forward:/cvpl/egovCvplCnsltList.do";
}
전자정부프레임워크에서 트랜잭션 메소드를 컨트롤러에 등록하여 사용할시 forward나 return 경로를 사용할 경우 중복으로 저장되는 현상이 발생한다.
그럴 경우 트랜잭션 컨트롤러의 패러미터 부분에
SessionStatus를 걸고 return 하기 전에 세션을 마무리 해주면 된다!(매우 중요)
-아버지 모시고 내가 운전하기
-부모님께 내가 만든 음식 차려드리기
-유언장 작성하기
-내 장례식 준비
-내 인생 이야기 집필과 출판 보기
-치아 교정 및 미백
-정말 좋은 여자 찾기
-브로드웨이 오리지널 뮤지컬 보기
-광안리에서 여름휴가 보내기
-훌륭한 요리 조리법 배워 디너파티 열기
-성경 읽기
-오픈카 타보기
-일본 북해도 눈여행하기
-고래 구경
-라틴댄스 배우기
-모리셔스 또는 몰디브에서 휴가 보내기
-1년동안 매달 소액기부하기
-번지점프해보기
-강원랜드에서 카지노게임 해보기
-골프 배우기
-스키타기
-마당있는 집에 살아보기
-토익시험보기
-애인보자마자 아무말 없이 키스해보기
-커플링 업그레이드 해보기
-아무준비 없이 바다로 떠나보기
-5분동안 아무 말없이 애인 안아보기
-체중 60키로대로 감량하기
-헤어스타일 바꿔보기
-공공장소에서 키스해보기
-사람많은데서 사랑한다고 외쳐보기
-부모님께 사랑한다고 말해보기
-적금 현금으로 받아보기
-한사람을 위한 공연해보기
-결혼해보기
-여자친구 감동의 눈물흘리게 해보기
-명품 선글라스 장만하기
-부모님 안아보기
-대학원 가기
-자격증 10개 따기
... To be continue
-이젠 죽어도 여한이 없을 만큼 행복해하기.
-End
시간 아깝다고, 돈 아깝다고 시도하지 않던 나의 소망은
하루를 넘기지 못하고 삶을 놓는 그들에게는 눈물의 소망이다.
시도할 수 있다는 기회조차 내겐 크나큰 축복이라고 생각하자.
http://blog.naver.com/jsharp83?Redirect=Log&logNo=110034118340
We were building a new web application recently, and being in a position to influence the development, I promptly chose to use theMaven2 web application directory structure. Spring is now our web application framework of choice, so that was a given. We have also had very good results with Tiles in our legacy web application, thanks to the efforts of one of my colleagues, so we also wanted to use Tiles here. I had set up a web application at my previous job to work with Spring and Tiles about 3 years ago, but the details were hazy, and the Tiles integration in our legacy application uses some proprietary components, so I decided to figure this out afresh for this project. Surprisingly, there does not seem to be much documentation about Spring/Tiles integration on the web, but I was able to build an example by piecing together information from various sources, which I describe here. Hopefully, the information will help someone in a similar situation.
We start off with a standard Spring application, with the web.xml containing a reference to the Spring DispatcherServlet, as shown below. The web.xml file lives in src/main/webapp/WEB-INF
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
|
The myapp-servlet.xml referenced by the web.xml above. The myapp-servlet.xml also lives in src/main/webapp/WEB-INF and is shown below. The myapp-servlet.xml sets up the TilesConfigurer with the location of the tiles configuration file (tiles-def.xml), sets up the Tiles view resolver, and specifies the URL mappings to the respective Spring controllers. It also imports non-web bean definitions from the applicationContext.xml in src/main/resources. This is a personal preference, since I like to be able to unit test the non-web components using JUnit, and breaking this up into a separate configuration file makes this easier.
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 32 33 34 35 36 37 38 39 40 |
<?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:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.0.xsd">
|
We then define the various tiles. Our example layout contains 4 tiles, one each for static content for the header and footer, one for the left navigation toolbar, and one for the main body of the page. The tiles-def.xml lives in src/main/webapp/WEB-INF and is shown below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">
<tiles-definitions>
|
Currently the only dynamic component is the main body, which uses the "who" parameter to fill out the "Hello ${who}" header. All others are static. The example.jsp page appears below, followed by the different tiles. The locations are in the path attribute in the definitions in the tiles-def.xml file. The root is at src/main/webapp, so /example is actually src/main/webapp/example.
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 |
<%-- src/main/webapp/example/example.jsp --%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<html>
<head><title>Example Page</title></head>
<body>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td colspan="2">
<tiles:insert attribute="head-position"/>
</td>
</tr>
<tr>
<td width="25%">
<tiles:insert attribute="left-nav-position"/>
</td>
<td width="75%">
<tiles:insert attribute="body-position"/>
</td>
</tr>
<tr>
<td colspan="2">
<tiles:insert attribute="foot-position"/>
</td>
</tr>
</table>
</body>
</html>
|
I realize that using table tags to layout pages are kind of frowned upon nowadays, but if you have been reading my posts, you will realize that I am not exactly a UI guru. So please bear with me, and mentally replace the table tags with the appropriate CSS magic that is less offensive. The tiles are quite simple, and they are shown below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<!-- src/main/webapp/example/tiles/head.jsp -->
<h1>Da Korporate Header go here</h1>
<!-- src/main/webapp/example/tiles/leftnav.jsp -->
<ol>
<li>Foo</li>
<li>Bar</li>
</ol>
<!-- src/main/webapp/example/tiles/body.jsp -->
<h2>Hello ${who}</h2>
... body text filler ...<!-- src/main/webapp/example/tiles/foot.jsp -->
<h1>Da Korporate Footer go here</h1>
|
So in effect, tiles have given us the ability to reuse JSP snippets on different pages. It is quite likely that the header and footer tiles, and perhaps the left nav tile, will be used across the entire application. So we need to create new tiles for only the body element for different applications.
The controller that backs this is referenced as exampleController in the myapp-servlet.xml and defined more fully in the applicationContext.xml file in src/main/resources. This file currently contains only the controller definition, but could be used to declare beans that the controller(s) depend on as well.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<?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:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.0.xsd"><!-- ExampleController -->
<bean id="exampleController" class="com.mycompany.myapp.example.ExampleController">
<property name="viewName" value="example"/>
</bean>
</beans>
|
The actual Java code is quite simple. All it does is pick up the parameter "who" from the URL, and pass it through to the view as a ModelAndView attribute. The java tree is rooted at src/main/java, in case you did not already know.
1 2 3 4 5 6 7 8 9 10 11 12 |
public class ExampleController extends ParameterizableViewController {public ModelAndView handleRequestInternal(HttpServletRequest request,
HttpServletResponse response) throws Exception {
String who = ServletRequestUtils.getStringParameter(request, "who");
ModelAndView mav = new ModelAndView();
mav.addObject("who", (who == null ? "NULL" : who));
mav.setViewName(getViewName());
return mav;
}
}
|
Start up the web application from the command line with "mvn jetty6:run" and hit the URL: http://localhost:8081/myapp/example.html?who=Sujit to see the following page:
We can also make certain tiles "smarter", in the sense that the Java logic backing these components need not be supplied by the main Spring controller, but can be specified separately. This can be useful when designing widgets for your web pages, which need to do significant processing on the request parameters before rendering the output. We could also refactor the logic out to some kind of service and have the main controller make a single call into it to get the renderable data, but this still means that we have to remember to pull data for each component in every new page controller we write. Specifying a controller for a tile is done in the controllerClass attribute in the tiles definitions.
For our example, we will make the left nav component smart. Depending on the value of the parameter "type" in the URL, it will display different lists. This requires specifying the controllerClass in the tiles definition for left-nav-tile in tiles-def.xml.
1 2 |
<definition name="left-nav-tile" path="/example/tiles/leftnav.jsp"
controllerClass="com.mycompany.myapp.example.LeftNavController"/>
|
The controller is not a Spring controller, but a Tiles Controller. The code for that is shown below:
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 |
public class LeftNavController extends ControllerSupport {
|
One small wrinkle. The type parameter has to be injected into the tile context for the left-nav tile. This is done by setting it in the layout example.jsp file from the request using a tiles:put element, like so:
1 2 3 4 5 6 7 8 9 10 11 12 |
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<html>
...
<td width="25%">
<tiles:insert attribute="left-nav-position">
<tiles:put name="type" value="${param.type}"/>
</tiles:insert>
</td>
...
</html>
|
The corresponding tile leftnav.jsp in src/main/webapp/example/tiles also has to be modified to show the "menu" object we just pushed into the context using the LeftNavController. Here it is:
1 2 3 4 5 6 7 |
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<ol>
<c:forEach var="menuItem" items="${menu}">
<li>${menuItem}</li>
</c:forEach>
</ol>
|
Now, hitting the application with http://localhost:8081/aetna/example.html?who=Sujit&type=1 will produce the following page, which shows us that the type parameter is being correctly interpreted.
So this is it. The whole thing is not terribly complicated, but requires you to mess with a lot of XML files. The good news is that working with Tiles can significantly speed up your web application development and make it easier, as well as enforce a uniform look and feel to your web application. And once you set it up, and developers get used to the process of adding components and layouts, it will just become second nature and you will wonder how you worked without Tiles.
출처 : http://sujitpal.blogspot.com/2007/06/springtiles-example-web-application-on.html
원저작자가 게시해 놓은거 보고 적용시켰는데 에러가 났다 ㅡ.,ㅡ;;;;
직접 사이트로 찾아들어가 확인해보니 디펜던시 설정은 다음과 같이 해야한다.
1. Repository
<dependency>
<groupId>org.springbyexample</groupId>
<artifactId>dynamic-tiles2</artifactId>
<version>1.1</version>
</dependency>
2. Dependency
<dependency>
<groupId>org.springbyexample</groupId>
<artifactId>dynamic-tiles2</artifactId>
<version>1.1</version>
</dependency>
이클립스에서 유니코드로 인코딩된 한글파일을 보려며 새로운 플러그인 추가에 다음 경로를 추가하여
properties editor를 설치한다.
http://propedit.sourceforge.jp/eclipse/updates
java.lang.IllegalStateException: Level number 20 is not recognized.
slf4j .1.3.x 버전을 사용할 때 나타나는 에러
slf4j 1.5.x 버전으로 바꾸면 된다.
전자정부프레임워크를 권장사항(?)에 따라
JDK 1.6, Tomcat 6 에서 돌리면
TagSupport, c.Tld 어쩌고 저쩌고 하는 에러가 날 수 있다.
이는 웹 어플리케이션의 WEB-INF/lib 디렉토리에 구동하는 톰캣의 jsp-api.jar, servlet-api.jar와 다른 버전의 라이브러리가 들어가서 그렇다.
컴파일러 빌드패스에서 개발환경에서 구동하는 톰캣의 servlet-api.jar와 jsp-api.jar 파일을 임포트 시켜서 WEB-INF/lib로 라이브러리 출력으로
설정을 걸어두던지 직접 TOMCAT/lib에서 위의 두 파일을 복사하면 말끔하게 태그라이브러리 관련한 에러가 사라진다.


