protected String parseValue(
      HttpServletRequest request, HttpServletResponse response, String control) {
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("user", SecurityUtils.getLoginUser());
    model.putAll(SecurityUtils.getShiroUser().getAttributes());

    WebApplicationContext context = RequestContextUtils.getWebApplicationContext(request);
    SimpleHash simpleHash =
        freeMarkerParse.buildTemplateModel(model, context.getServletContext(), request, response);

    return freeMarkerParse.renderString(control, simpleHash);
  }
 /**
  * 此方法描述的是:
  *
  * @author: zhangjh
  * @version: 2015年4月29日 下午5:35:09
  */
 @RequestMapping(value = "/edit", method = RequestMethod.POST)
 @ResponseBody
 public Map<String, Object> edit(
     BondingLaminationCoatingInfo areaInfo,
     HttpServletRequest request,
     HttpServletResponse respones) {
   bondingLaminationCoatingService.edit(areaInfo);
   ApplicationContext appContext = RequestContextUtils.getWebApplicationContext(request);
   BondingLaminationCoatingServiceHelper.SINGLETONE.refreshSelect(appContext);
   Map<String, Object> resultMap = new HashMap<String, Object>();
   resultMap.put("code", "0");
   resultMap.put("message", "更新成功");
   return resultMap;
 }
 /**
  * 此方法描述的是:
  *
  * @author: zhangjh
  * @version: 2015年4月29日 下午5:35:09
  */
 @RequestMapping(value = "/new", method = RequestMethod.POST)
 @ResponseBody
 public Map<String, Object> add(
     BondingLaminationCoatingInfo areaInfo,
     HttpServletRequest request,
     HttpServletResponse reareaonse) {
   String currentNo = bondingLaminationCoatingService.queryCurrentSeqNo();
   // 设置ID
   areaInfo.setNatrualkey(
       BuildSeqNoHelper.SINGLETONE.getNextSeqNo(
           TableNameConstant.BLC_INFO, currentNo, incrementNumber));
   bondingLaminationCoatingService.add(areaInfo);
   ApplicationContext appContext = RequestContextUtils.getWebApplicationContext(request);
   BondingLaminationCoatingServiceHelper.SINGLETONE.refreshSelect(appContext);
   Map<String, Object> resultMap = new HashMap<String, Object>();
   resultMap.put("code", "0");
   resultMap.put("message", "新增成功");
   return resultMap;
 }
Exemple #4
0
  /** @return A found BeanFactory configuration */
  private BeanFactory getBeanFactory() {
    // If someone has set a resource name then we need to load that.
    if (configLocation != null && configLocation.length > 0) {
      log.info(
          "Spring BeanFactory via ClassPathXmlApplicationContext using "
              + configLocation.length
              + "configLocations.");
      return new ClassPathXmlApplicationContext(configLocation);
    }

    ServletContext srvCtx = ServerContextFactory.get().getServletContext();

    HttpServletRequest request = null;
    try {
      request = WebContextFactory.get().getHttpServletRequest();
    } catch (Exception ex) {
      // Probably on boot time
    }

    return request != null
        ? RequestContextUtils.getWebApplicationContext(request, srvCtx)
        : WebApplicationContextUtils.getWebApplicationContext(srvCtx);
  }
Exemple #5
0
 /**
  * Returns the Spring bean with name <code>beanName</code> and of type <code>beanClass</code>.
  *
  * @param <T> type of the bean
  * @param httpRequest the http request
  * @param beanName name of the bean
  * @param beanClass expected type of the bean
  * @return the bean matching the given arguments or <code>null</code> if no bean could be resolved
  */
 public static <T> T getSpringBean(
     final HttpServletRequest httpRequest, final String beanName, final Class<T> beanClass) {
   return RequestContextUtils.getWebApplicationContext(
           httpRequest, httpRequest.getSession().getServletContext())
       .getBean(beanName, beanClass);
 }