public void render(String key, HttpServletRequest request, HttpServletResponse response, Object... args)
	{
		Writer writer = null;
		OutputStream os = null;
		String ajaxId = null;
		Template template = null;
		boolean isError = false;
		try

		{
			//			response.setContentType(contentType);
			int ajaxIdIndex = key.lastIndexOf("#");
			if (ajaxIdIndex != -1)
			{
				ajaxId = key.substring(ajaxIdIndex + 1);
				key = key.substring(0, ajaxIdIndex);
				template = gt.getAjaxTemplate(key, ajaxId);

			}
			else
			{
				template = gt.getTemplate(key);
			}

			Enumeration<String> attrs = request.getAttributeNames();

			while (attrs.hasMoreElements())
			{
				String attrName = attrs.nextElement();
				template.binding(attrName, request.getAttribute(attrName));

			}
			WebVariable webVariable = new WebVariable();
			webVariable.setRequest(request);
			webVariable.setResponse(response);
			template.binding(WebVariable.SESSION, new SessionWrapper(request,request.getSession(false)));

			template.binding(WebVariable.SERVLET, webVariable);
			template.binding(WebVariable.REQUEST, request);
			template.binding("ctxPath", request.getContextPath());
			template.binding("$page", new HashMap()); 
			template.binding("parameter", new ParameterWrapper(request));
			template.binding("cookie", new CookieFunction());
			

			modifyTemplate(template, key, request, response, args);

			String strWebAppExt = gt.getConf().getWebAppExt();
			if(strWebAppExt!=null){
				WebRenderExt renderExt = this.getWebRenderExt(strWebAppExt);
				renderExt.modify(template, gt, request, response);
			}
			
			
			if (gt.getConf().isDirectByteOutput())
			{
				os = response.getOutputStream();
				template.renderTo(os);
			}
			else
			{
				writer = response.getWriter();
				template.renderTo(writer);
			}

		}
		catch (IOException e)
		{
			isError = true;
			handleClientError(e);
		}
		catch (BeetlException e)
		{
			isError = true;
//			response.setStatus(500);
//			
			handleBeetlException(e);
		}

		finally
		{
			try
			{
				
				if (!isError&&writer != null)
					writer.flush();
				if (!isError&&os != null)
				{
					os.flush();
				}
			}
			catch (IOException e)
			{
				handleClientError(e);
			}
		}
	}
public void render ( String key , HttpServletRequest request , HttpServletResponse response , Object ... args ) { Writer writer = null ; OutputStream os = null ; String ajaxId = null ; Template template = null ; boolean isError = false ; try { int ajaxIdIndex = key . lastIndexOf ( "#" ) ; if ( ajaxIdIndex != - 1 ) { ajaxId = key . substring ( ajaxIdIndex + 1 ) ; key = key . substring ( 0 , ajaxIdIndex ) ; template = gt . getAjaxTemplate ( key , ajaxId ) ; } else { template = gt . getTemplate ( key ) ; } Enumeration < String > attrs = request . getAttributeNames ( ) ; while ( attrs . hasMoreElements ( ) ) { String attrName = attrs . nextElement ( ) ; template . binding ( attrName , request . getAttribute ( attrName ) ) ; } WebVariable webVariable = new WebVariable ( ) ; webVariable . setRequest ( request ) ; webVariable . setResponse ( response ) ; template . binding ( WebVariable . SESSION , new SessionWrapper ( request , request . getSession ( false ) ) ) ; template . binding ( WebVariable . SERVLET , webVariable ) ; template . binding ( WebVariable . REQUEST , request ) ; template . binding ( "ctxPath" , request . getContextPath ( ) ) ; template . binding ( "$page" , new HashMap ( ) ) ; template . binding ( "parameter" , new ParameterWrapper ( request ) ) ; template . binding ( "cookie" , new CookieFunction ( ) ) ; modifyTemplate ( template , key , request , response , args ) ; String strWebAppExt = gt . getConf ( ) . getWebAppExt ( ) ; if ( strWebAppExt != null ) { WebRenderExt renderExt = this . getWebRenderExt ( strWebAppExt ) ; renderExt . modify ( template , gt , request , response ) ; } if ( gt . getConf ( ) . isDirectByteOutput ( ) ) { os = response . getOutputStream ( ) ; template . renderTo ( os ) ; } else { writer = response . getWriter ( ) ; template . renderTo ( writer ) ; } } catch ( IOException e ) { isError = true ; handleClientError ( e ) ; } catch ( BeetlException e ) { isError = true ; handleBeetlException ( e ) ; } finally { try { if ( ! isError && writer != null ) writer . flush ( ) ; if ( ! isError && os != null ) { os . flush ( ) ; } } catch ( IOException e ) { handleClientError ( e ) ; } } }
@param key 模板资源id
@param request
@param response
@param args 其他参数，将会传给modifyTemplate方法