zoukankan      html  css  js  c++  java
  • 全局请求参数去除空格

    package com.ustcinfo.fn.config;
    
    import org.springframework.beans.propertyeditors.CustomDateEditor;
    import org.springframework.beans.propertyeditors.StringTrimmerEditor;
    import org.springframework.web.bind.WebDataBinder;
    import org.springframework.web.bind.annotation.ControllerAdvice;
    import org.springframework.web.bind.annotation.InitBinder;
    import org.springframework.web.bind.support.WebBindingInitializer;
    <!--more-->
    import java.text.SimpleDateFormat;
    import java.util.Date;
    
    /**
     * 全局请求参数去除空格 string转date
     *
     * @author Jamin
     * @date 2020/9/21 17:03
     */
    @ControllerAdvice
    public class MyStringTrimmerEditor implements WebBindingInitializer {
    
    	@Override
    	@InitBinder
    	public void initBinder(WebDataBinder binder) {
    		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
    		simpleDateFormat.setLenient(false);
    		binder.registerCustomEditor(Date.class, new CustomDateEditor(simpleDateFormat, true));
    		binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
    	}
    }
    
    
    作者: JaminYe
    版权声明:本文原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
  • 相关阅读:
    委托
    反射
    ADO.net五大对象
    DNS协议详解
    FTP协议详解
    .Net 多线程 异步编程 Await、Async和Task
    AsnycLocal与ThreadLocal
    Angular 6.X CLI(Angular.json) 属性详解
    Angular Npm Package.Json文件详解
    Npm常用命令整理
  • 原文地址:https://www.cnblogs.com/JaminYe/p/13940697.html
Copyright © 2011-2022 走看看