framememarker 템플릿 분석 및 백그라운드 조정 방법, 백그라운드 템플릿 만들기

2744 단어 ftl

템플릿 해결

// 
		Map data=new HashMap();
		data.put("siteid", siteInfo.getsiteid());
		data.put("name", this.getCurrentUser().account);
		data.put("menuid", setSiteID());
		// 
		data.put("controller",new SiteinfoController());

		// framemarker 
		Configuration cfg = new Configuration();

		// framemarker 
		cfg.setServletContextForTemplateLoading(request.getSession().getServletContext(),
						"sites"+File.separator+ siteInfo.getalias() + File.separator + "install" );//ftl 

		// 
		cfg.setEncoding(Locale.getDefault(), "UTF-8");

		// 
		File f = new File(wirteurl + File.separator + "install" + File.separator + "data.sql");
		Writer out = null;
		try {
			
			// 
			Template t = cfg.getTemplate("data.ftl");
			
			// , 
			out = new BufferedWriter(new FileWriterWithEncoding(f,"UTF-8"));
			
			// 
			t.process(data, out); 
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			log.error("execute framemarker error");
			e.printStackTrace();
			
		// 
		}finally{
            if(out != null){
                try {
                    out.flush();
                    out.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }            
        }

백그라운드 생성 ftl 템플릿, 변수 포함, 동적 백그라운드 조정 방법

// ftl 
		// 
		String categorySql = "insert into t_content_category(CATEGORYID,MODULEID,SITEID,NAME,DESCRIPTION,PARENTID,DEPTH,VIEWORDER" +
						",ADMINROLES,EDITROLES,VIEWROLES,CREATEDBYUSER,CREATEDDATE,ISACTIVE,URL,COMMENTROLES) values('"
						+ category.getCategoryid() + "','"
						+ category.getModuleid() + "','" + "${siteid}','"
						+ category.getName() + "','"
						+ category.getDescription() + "','"
						+ category.getParentid() + "','" + category.getDepth()
						+ "','" + category.getVieworder() + "','"
						+ category.getAdminroles() + "','"
						+ category.getEditroles() + "','"
						+ category.getViewroles() + "','"
						+ "${name}" + "'," + "NOW(),'"
						+ category.getIsactive() + "','" + category.getUrl()
						+ "','" + category.getCommentroles() + "');";
		// 
		leftStr += "";
				 str = str.replaceAll(moduleLst.get(j).getInstanceid(),
						 java.util.regex.Matcher.quoteReplacement("${var" + count + "}"));

좋은 웹페이지 즐겨찾기