ControllerExportTemplate.ftl 1.77 KB
package ${mainPackageInfo}.${moduleName}.export;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taover.base.ResultInfo;
import ${mainPackageInfo}.contants.ResultInfoCode;
import com.taover.tools.CustomTimestampEditor;

@Controller
@RequestMapping("/export/${moduleName}")
public class ${moduleNameFirstBig}ExportController {
	
	Log log = LogFactory.getLog(this.getClass());
	
	/**
	 * 绑定日期参数
	 * @param request
	 * @param binder
	 */
    @InitBinder  
    protected void init(HttpServletRequest request, WebDataBinder binder){  
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");  
        dateFormat.setLenient(false);  
        binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));  
        SimpleDateFormat datetimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
   		datetimeFormat.setLenient(false);
   		binder.registerCustomEditor(java.sql.Timestamp.class,new CustomTimestampEditor(datetimeFormat, true));
    }
    
}