본문 바로가기

Tip/Spring

(16)
[Spring + Thymeleaf] 국제화 메세지 처리 Thymeleaf 에서 메세징 처리를 위해서는 다음과 같이 적용할 수 있다. servlet-context.xml META-INF/message/messages 에 파일 추가 messages_en.propertiestest=testtest.param=Test {0} messages_ko.propertiestest=테스트test.param=테스트 {0} Test.html 에서의 thymeleaf 문법 또는 기본값기본값 기본값 ${#messages.msg('test')} 는 test 키 값이 없을 경우 ??test?? 라는 기본 메세지 형태로 출력이 되고${#messages.msgOrNull('test')} 의 경우에는 null 을 리턴한다. 위의 설정대로 진행하면 URL 요청시 파라메터로 ?lang=en, ..
jsdoc3 maven plugin 사용법 jsdoc 을 이용하면 javadoc 과 같이 javascript 파일에 대한 api 를 자동으로 생성할 수 있다. 물론 jsdoc 생성과 관련한 주석에 대한 규칙을 알아야 하지만 이번에는 jsdoc3와 maven 의 연동에 대해서만 짧게 작성하려 한다. 우선 사용한 jsdoc3-maven-plugin 은 여기에 잘 설명되어 있다. 그중 내가 사용한 부분의 코드는 다음과 같다. com.github.phasebashjsdoc3-maven-plugin1.0.7 com.github.phasebash jsdoc3-maven-plugin 1.0.7 true ${basedir}/src/main/webapp/resources/js ${basedir}/src/main/javascript Run the Mojo.mvn ..
Controller 에서의 Async 사용시 Spring security 와의 충돌(?) Controller 에서 Async 사용을 위해 Callable 사용시 Spring security 와의 충돌 현상이 발생하였다. (즉, Spring security 의 세션 정보가 날라가는 현상이다. ) 증상이 발생한 Spring, Security 버전Spring version : 3.2.5.RELEASESpring security version : 3.1.4.RELEASE Spring security 의 upgrade 버전에서는 해결하였다고 한다. 하지만 release 버전은 아니라는 점.... 해결 버전Spring version : 3.2.5.RELEASESpring security version : 3.2.0.RC2 참고 ) http://stackoverflow.com/questions/19107..
Redirect를 Post 요청으로? 기본적으로 POST 로 요청이 들어온 것에 대해서 model 에 값들을 넣어 redirect: 하면 get방식으로 요청하고 파라메터들이 쭈루룩 붙어서 요청이 되는 것을 확인할 수 있는데 이때 불필요한 파라메터를 제거하는 방법이 바로 아래의 코드를 이용할 수 있다. RedirectView rv = new RedirectView("/view.do");rv.setExposeModelAttributes(false); 허나 이것이 아니라 POST 로 요청을 하고 싶은 경우에 RedirectAttributes , FlashMap 등을 이용하여 전달할 수 있다고 한다. 일단 이정도 적고 나중에 좀 더 길게 해보자. 참고 http://kst.codns.com/crooner/?p=43http://redtrain.tist..
스프링(Spring) 에서의 리다이렉트(redirect:) 스프링에서 "redirect:" 를 사용했을때 기준은 현재 서블릿컨텍스트라고 한다. 이때 외부 페이지나 서블릿컨텍스트가 다른 경우에는 절대 URL 경로를 "redirect:" 이후에 지정해야 원하는 페이지로 이동하는 것을 확인할 수 있겠다. public static String getURLWithContextPath(HttpServletRequest request) { return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();} 참고)http://docs.spring.io/spring/docs/current/spring-framework-refere..
[Thymeleaf] Thymol Static Imports 제목에서 말하듯 Thymeleaf 를 사용시 Thymol 을 통해 html 파일에서의 정적임포트가 가능하다. Thymeleaf 를 이용하여 include 한 파일을 jquery 의 get() 을 통해 해당 위치를 태그를 대체하는 형태로 동작하는데 크롬에서는 다음과 같은 에러를 발생하며 작동하지 않는다. (버전 28.0.1500.95 m) Failed to load resource: Origin null is not allowed by Access-Control-Allow-Origin. file:///C:/dev/workspace/proj1/src/main/webapp/WEB-INF/views/common/menu.html 이때 해당 사이트에서 제시한 아래의 방법을 적용하면 정적인 임포트가 가능하다. 그렇..
Thymeleaf Extras Thymeleaf - Tiles 2 integration module https://github.com/thymeleaf/thymeleaf-extras-tiles2 Thymeleaf - Module for Internet Explorer conditional comments https://github.com/thymeleaf/thymeleaf-extras-conditionalcomments
spring MVC + tiles 2.2.2 본 포스팅은 STS로부터 생성된 Spring MVC 를 기반으로 한다. 개요 레이아웃 프레임워크로 많이 사용하는 tiles 를 spring MVC 와 연동하는 것을 순서대로 적어본다. pom.xml pom.xml 파일에 tiles 설정과 관련한 라이브러리를 선언한다. 참고로 2012-07-11 에 Version: 3.0.1 이 릴리즈 되었다. 하지만 이 포스팅에서는 2.2.2 를 사용해보도록 한다. 1.63.1.1.RELEASE1.6.101.6.62.2.2 org.apache.tilestiles-extras${org.apache.tiles-version} servlet-context.xml 기존의 InternalResourceViewResolver 대신 TilesViewResolver 를 등록한다. ti..