numberformat注解,numberformat用法

http://www.itjxue.com  2023-01-17 02:01  来源:未知  点击次数: 

@enablewebmvc注解有什么用途?

@enablewebmvc注解有什么用途:

@EnableWebMvc是使用Java 注解快捷配置Spring Webmvc的一个注解。在使用该注解后配置一个继承于WebMvcConfigurerAdapter的配置类即可配置好Spring Webmvc。

通过查看@EnableWebMvc的源码,可以发现该注解就是为了引入一个DelegatingWebMvcConfiguration Java 配置类。并翻看DelegatingWebMvcConfiguration的源码会发现该类似继承于WebMvcConfigurationSupport的类。

其实不使用@EnableWebMvc注解也是可以实现配置Webmvc,只需要将配置类继承于WebMvcConfigurationSupport类即可。

内容:

Spring 3 风格的类型转换 -- 通过一个ConversionService 实例 配合JavaBean PropertyEditors,用于Data Binding。

支持@NumberFormat注解通过ConversionService 来格式化Number字段。

支持使用@DateTimeFormat注解来格式化Date、Calendar、Long、以及Joda Time字段。

支持使用@Valid校验@Controller input -- 如果classpath中存在一个JSR-303 Provider。

HttpMessageConverter支持@RequestMapping或@ExceptionHandler method的 @RequestBody method parameters和@ResponseBody method 返回值。

比较长,其实就是支持handler (controller)的@RequestBody参数/@ResponseBody返回值。

9、注解篇@NumberFormat

– style:类型为 NumberFormat.Style。用于指定样式类

型,包括三种:Style.NUMBER(正常数字类型)、

Style.CURRENCY(货币类型)、 Style.PERCENT(

百分数类型)

– pattern:类型为 String,自定义样式,

如patter="#,###"

spring mvc + hibernate注解开发,报错java.lang.NumberFormatException: For input string: "topic_id"

java.lang.NumberFormatException: For input string: "topic_id"

这不是很明显的错误吗?

你的id是string,但是类型是数字型的,所以出现了转换错误。

应该是string对数字处理那个映射类你没加

spring页面到后台绑定的那个类

(责任编辑:IT教学网)

更多

推荐思科认证文章