@RequestMapping("/cvpl/updateCvplCnsltBest.do")
    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 하기 전에 세션을 마무리 해주면 된다!(매우 중요)

THE BUCKET LIST

2010/06/15 02:04 | Posted by Royalvip
-여자친구 졸업식 축하해주기
-아버지 모시고 내가 운전하기
-부모님께 내가 만든 음식 차려드리기
-유언장 작성하기
-내 장례식 준비
-내 인생 이야기 집필과 출판 보기
-치아 교정 및 미백
-정말 좋은 여자 찾기
-브로드웨이 오리지널 뮤지컬 보기
-광안리에서 여름휴가 보내기
-훌륭한 요리 조리법 배워 디너파티 열기
-성경 읽기
-오픈카 타보기
-일본 북해도 눈여행하기
-고래 구경
-라틴댄스 배우기
-모리셔스 또는 몰디브에서 휴가 보내기
-1년동안 매달 소액기부하기
-번지점프해보기
-강원랜드에서 카지노게임 해보기
-골프 배우기
-스키타기
-마당있는 집에 살아보기
-토익시험보기
-애인보자마자 아무말 없이 키스해보기
-커플링 업그레이드 해보기
-아무준비 없이 바다로 떠나보기
-5분동안 아무 말없이 애인 안아보기
-체중 60키로대로 감량하기
-헤어스타일 바꿔보기
-공공장소에서 키스해보기
-사람많은데서 사랑한다고 외쳐보기
-부모님께 사랑한다고 말해보기
-적금 현금으로 받아보기
-한사람을 위한 공연해보기
-결혼해보기
-여자친구 감동의 눈물흘리게 해보기
-명품 선글라스 장만하기
-부모님 안아보기
-대학원 가기
-자격증 10개 따기
-클레이사격하기

... To be continue

-이젠 죽어도 여한이 없을 만큼 행복해하기.
-End

시간 아깝다고, 돈 아깝다고 시도하지 않던 나의 소망은
하루를 넘기지 못하고 삶을 놓는 그들에게는 눈물의 소망이다.

시도할 수 있다는 기회조차 내겐 크나큰 축복이라고 생각하자.

자바에서 착각하기 쉬운 것들

2010/04/21 23:51 | Posted by Royalvip

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">
<servlet>
<servlet-name>myapp</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet><servlet-mapping> <servlet-name>myapp</servlet-name> <url-pattern>*.html</url-pattern> </servlet-mapping> </web-app>

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">
<import resource="classpath:applicationContext.xml" />
<bean id="tilesConfigurer"
class="org.springframework.web.servlet.view.tiles.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles-def.xml</value>
</list>
</property>
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="requestContextAttribute" value="requestContext"/>
<property name="viewClass"
value="org.springframework.web.servlet.view.tiles.TilesView"/>
</bean>
<!-- URL Mappings -->
<bean id="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="alwaysUseFullPath" value="true"/>
<property name="mappings">
<props>
<prop key="/example.html">exampleController</prop>
</props>
</property>
</bean></beans>

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>
<!-- Components -->
<definition name="head-tile" path="/example/tiles/head.jsp"/>
<definition name="left-nav-tile" path="/example/tiles/leftnav.jsp"/>
<definition name="body-tile" path="/example/tiles/body.jsp"/>
<definition name="foot-tile" path="/example/tiles/foot.jsp"/>
<!-- Pages --><!-- Example --> <definition name="example" path="/example/example.jsp"> <put name="head-position" value="head-tile"/> <put name="left-nav-position" value="left-nav-tile"/> <put name="body-position" value="body-tile"/> <put name="foot-position" value="foot-tile"/> </definition> </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 {
private String[][] menuItems = {
new String[] {"Foo", "Bar"},
new String[] {"London", "New York", "San Francisco", "Brussels"},
new String[] {"Engineering", "Finance", "Marketing"}
};public void execute(ComponentContext tileContext, HttpServletRequest request, HttpServletResponse response, ServletContext servletContext) throws Exception { // decide what kind of menu to show based on parameter "type" String menuTypeStr = (String) tileContext.getAttribute("type"); int menuType = 0; try { menuType = Integer.parseInt(menuTypeStr); } catch (NumberFormatException e) {} if (menuType < 0 || menuType > (menuItems.length - 1)) { menuType = 0; } String[] selectedMenuItem = menuItems[menuType]; request.setAttribute("menu", selectedMenuItem); } }

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

Dynamic Tiles2 Maven Repository

2010/04/19 17:59 | Posted by Royalvip

원저작자가 게시해 놓은거 보고 적용시켰는데 에러가 났다 ㅡ.,ㅡ;;;;

직접 사이트로 찾아들어가 확인해보니 디펜던시 설정은 다음과 같이 해야한다.

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

[에러] lelvel numver 20 is not recognized.

2010/04/08 16:31 | Posted by Royalvip

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에서 위의 두 파일을 복사하면 말끔하게 태그라이브러리 관련한 에러가 사라진다.

2010-04-05 23:58:46,831 ERROR [org.springframework.web.context.ContextLoader] Context initialization failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘egovJDBCAppender’: Autowiring of methods failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void egovframework.rte.fdl.logging.db.EgovJDBCAppender.setDataSource(javax.sql.DataSource); nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [javax.sql.DataSource] is defined:


이런 에러가 날 때가 있다.

전자정부 프레임워크 사이트에서는 관리자가 귀찮아서 알려주는 짓 따위 안한다.

그래서 혼자 두시간 동안 삽질한 결과 ..

..

..



public class EgovJDBCAppender extends JDBCAppender {


/** 로그 실행 위치 정보 flag */

boolean locationInfo = false;


/** 싱글톤 dataSource provider - Spring 연동 dataSource 제공 */

private final SingletonDataSourceProvider provider;


/**

   * ‘@Autowired’ Annotation 형식으로 dataSource 를 받아와 이를 SingletonDataSourceProvider 의 setDataSource 메서드를 호출하여 설정해 준다.

   * @param dataSource

   * - Spring 에서 설정한 dataSource

   */

@Resource(name = “dataSource”) <— 여기의 주석을 지워주면 된다.

@Autowired(required = false)

public void setDataSource(DataSource dataSource) {

provider.setDataSource(dataSource);

}





그렇다. 아래의 주석만 지워주면 되는 것이었다…

어쩌라구.. ㅠ_ㅡ

@Resource(name = “dataSource”)

제가 직접 설치를 해보면서 진행중인데 가이드 사이트에 올라와있는 그대로 사용하면 MYSQL은 에러납니다.

오라클 쪽은 아직 셋팅을 안해봐서 모르겠습니다.

MYSQL 쪽이 에러가 나는 이유는 테이블 생성시 Foreign-Key를 걸 때 부모와 자식 테이블의 순서가 바뀌어서 걸리지 않기 때문에 에러가 납니다.

일일히 찾아가면서 순서를 맞추어 다시 배포합니다.

유용하게 쓰시길 바랍니다.

첨부파일을 다운받아서 사용하시면 됩니다.


참고로 이 스크립트는 기본적으로 com 이라는 DB를 생성해 공통 컴포넌트 관련 테이블을 생성하도록 스크립팅 되어 있습니다.

별도의 DB를 사용하시려면

1단계 스크립트의 첫부분에서 DB create 부분과 use DB관련 부분 수정해서 사용하시면 되겠습니다.=

해당 가이드 페이지 링크

이전 1 2 3 다음