一、springmvc的xml配置文件
xmlns:xsi="/2001/XMLSchema-instance"
xmlns:context="/schema/context"
xmlns:mvc="/schema/mvc"
xsi:schemaLocation="/schema/beans
/schema/beans/spring-beans.xsd
/schema/context
/schema/context/spring-context.xsd
/schema/mvc
/schema/mvc/spring-mvc.xsd">
二、转换的类
package com.wuxi.utils;
import org.springframework.core.convert.converter.Converter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class StringToDateConverter implements Converter {
@Override
public Date convert(String string) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date = null;
try {
date = sdf.parse(string);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
}
三、接口
@RequestMapping("/student")
public String student(Student student, HttpServletRequest request, HttpServletResponse response) {
System.out.println(student);
return "success";
}
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。