当前位置: 代码迷 >> Java Web开发 >> springmvc4 + thymeleaf 表单提交出现500异常
  详细解决方案

springmvc4 + thymeleaf 表单提交出现500异常

热度:115   发布时间:2016-04-13 22:16:08.0
【求助】 springmvc4 + thymeleaf 表单提交出现500错误?



<form action="#" th:action="@{/signinValidation}" th:object="${AdminSignin}" method="post"> 
        <div class="form-group mb10">
          <div class="input-group">
            <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
            <input type="text" class="form-control" placeholder="Enter Username" name="adminName" th:field="*{adminName}" />
          </div>
        </div>
        <div class="form-group nomargin">
          <div class="input-group">
            <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
            <input type="password" class="form-control" placeholder="Enter Password" name="adminPass" th:field="*{adminPass}" />
          </div>



package com.jxanyway.cpm.entity;

public class AdminSignin {

private String adminName;
private String adminPass;
.....get ,set 



@RequestMapping(value="/signinValidation", method=RequestMethod.POST)
public String signigValidation(AdminSignin adminSignin) {

System.out.println(adminSignin.toString());
return "index";
}



------解决思路----------------------
AdminSignin不是HttpRequest的子类,编译器不会自动将数据转换成AdminSignin类型的。做法:public class AdminSignin extends StringAndEqualsObject  或者 public class AdminSignin implements Model
  相关解决方案