控制器

@Controller
public class MyController {

    // 处理器方法
    @RequestMapping(value = "/first.do")
    public String doFirst(Date birthday, int age) {
        return "/jsp/two.jsp";
    }

    // 自定义一个方法
    @InitBinder
    public void initBinder(WebDataBinder binder) {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        //0需要返回的类型,1传入一个带格式的df,2允许为空
        binder.registerCustomEditor(Date.class, new CustomDateEditor(df, true));
    }
}

 

相关文章:

  • 2021-11-28
  • 2021-07-24
  • 2022-02-27
  • 2021-05-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-03
猜你喜欢
  • 2022-12-23
  • 2021-04-25
  • 2022-01-03
  • 2022-12-23
  • 2022-12-23
  • 2021-12-22
相关资源
相似解决方案