springMVC自定义数据类型转换器
(1) 将string类型转换为date类型
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/converter")
public class ConverterHandler {
@RequestMapping("/test")
public String test( int id){
System.out.println(id);
return "index";
}
}
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.Date;
@Controller
@RequestMapping("/converter")
public class ConverterHandler {
@RequestMapping("/test")
public String test( Date date){
System.out.println(date);
return "index";
}
}
test.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>