사용자 도구

사이트 도구


groovy:groovlet

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
groovy:groovlet [2012/09/05 18:31]
kwon37xi [기본 내장 객체 목록]
groovy:groovlet [2012/09/07 11:10]
kwon37xi
줄 47: 줄 47:
 </code> </code>
  
-* contextPath : ''${context.contextPath}''+  * contextPath : ''context.contextPath''
 ===== session ===== ===== session =====
 세션 사용시 주의해야 한다. session 내장 객체가 null 일수 있기 때문이다. 세션 사용시 주의해야 한다. session 내장 객체가 null 일수 있기 때문이다.
줄 99: 줄 99:
   * ''<% out << 평가식 %>'' : 평가결과 출력   * ''<% out << 평가식 %>'' : 평가결과 출력
   * ''$평가식'' : 평가 결과 출력   * ''$평가식'' : 평가 결과 출력
 +
 +===== 사용자 정의 내장 객체 넣기 =====
 +GroovyServlet과 TemplateServlet을 상속받아서 [[http://groovy.codehaus.org/api/groovy/servlet/AbstractHttpServlet.html#setVariables%28groovy.servlet.ServletBinding%29|protected void setVariables()]] 를 Override한 뒤에 ServetletBinding 객체에 자신이 원하는 객체를 더 넣어주면 Groovlet과 Template에서 내장 객체로 사용할 수 있다.
 +
 +web.xml 에서 servlet-mapping 등록은 자신이 만든 클래스로 변경해줘야 한다.
 +<code java>
 +public class LogViewerTemplateServlet extends TemplateServlet {
 +
 + private static final long serialVersionUID = 1L;
 +
 + @Override
 + protected void setVariables(ServletBinding binding) {
 + HttpServletRequest request = (HttpServletRequest)binding.getVariable("request");
 + HttpServletResponse response = (HttpServletResponse)binding.getVariable("response");
 + ServletContext context = (ServletContext)binding.getVariable("context");
 +
 + binding.setVariable("ht", new HtmlTools(context, request, response));
 + }
 +}
 +
 +</code>
 +
 +
  
groovy/groovlet.txt · 마지막으로 수정됨: 2012/09/07 11:10 저자 kwon37xi