废话我就不说了,直接进入主题了,先来一张思维导图
如图要实现SpringMVC自定义类型转换器主要有两步,自定义类实现Convert接口和Spring配置文件中配置转换器
下面是我写的一个小dome供大家参考:
(1).配置pom.xml
<dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> <!-- 引入Spring web mvc依赖--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>4.3.3.RELEASE</version> </dependency> <!-- 引入servlet 依赖--> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</