`

Http 400 Bad Request

阅读更多
今天在提交form的时候碰到这个错误, 错误原因是数据类型前台和后台不一致。

代码如下:


@Controller
public class NameController
{
	
	@RequestMapping(value="/myname",method=RequestMethod.POST)
	public String testName(Integer myName){
		System.out.println(myName);
		
		return null;
	}
}



 <body>
    This is my JSP page. <br>
    
    <form action="myname" method="post" >
    	<input type="text" value="hello" name="myName">
    	<input type="submit" value="sumbit">
    </form>
    
  </body>


由于后台接受Integer类型,而前台输入的是'hello', 就会出现这个错误。
只不过springmvc是不会报出任何错误信息的, 所以排查起来比较麻烦。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics