首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

spring3 @RequestPrama 400异常

2013-03-04 
spring3 @RequestPrama 400错误http://blog.csdn.net/hellostory/article/details/7519358?错误描述:?[jav

spring3 @RequestPrama 400错误

http://blog.csdn.net/hellostory/article/details/7519358

?

错误描述:

?

[java]?view plaincopy
  1. @RequestMapping(value?=?"/index")??
  2. ????public?String?index(@RequestParam(value?=?"action",?required?=?false)??
  3. ????String?action,?@RequestParam(value?=?"notIncludeTypeId",?required?=?false)??
  4. ????int?notIncludeTypeId){??
  5. ????//?....?省略代码??
  6. }??

?

? ? ? 当可选参数“notIncludeTypeId”为空时,系统出现如下错误:?

?

[plain]?view plaincopy
  1. Optional?int?parameter?'notIncludeTypeId'?is?not?present???
  2. but?cannot?be?translated?into?a?null?value?due?to?being?declared?as?a?primitive?type.???
  3. Consider?declaring?it?as?object?wrapper?for?the?corresponding?primitive?type.??

?

错误原因:

? ? 可选参数“notIncludeTypeId”不存在时,Spring默认将其赋值为null,但由于notIncludeTypeId已定于为基本类型int,所赋值失败!

解决方法:

? ? “Consider declaring it as object wrapper for the corresponding primitive type.”建议使用包装类型代替基本类型,如使用“Integer”代替“int”

?

?

null 和?

热点排行