Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring mvc java.lang.IllegalStateException:bean name';注册bean';可用作请求属性_Spring Mvc_Spring Annotations - Fatal编程技术网

Spring mvc java.lang.IllegalStateException:bean name';注册bean';可用作请求属性

Spring mvc java.lang.IllegalStateException:bean name';注册bean';可用作请求属性,spring-mvc,spring-annotations,Spring Mvc,Spring Annotations,我得到一个例外: java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'RegistrationBean' available as request attribute 这是我的控制器类 @Controller public class TenantRegistrationController { @Autowired private

我得到一个例外:

    java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'RegistrationBean' available as request attribute
这是我的控制器类

@Controller
public class TenantRegistrationController {

    @Autowired
    private TenantService tenantService;

    @Autowired
    private UserService userService;
RegistrationBean是作为模型属性从jsp传递的bean类

    @RequestMapping(value="/registration", method= RequestMethod.POST)
    public String addNewTenant(@ModelAttribute("RegistrationBean")RegistrationBean registrationBean, 
            BindingResult result, Map<String,Object> map)
    {
        Tenant tenant = new Tenant();

        tenant.setTenant_name(registrationBean.getTenantName());
        tenant.setTenant_email(registrationBean.getTenantEmail());
        tenant.setAddress(registrationBean.getTenantAddress());
//      tenant.setReminder_email(Integer.parseInt(registrationBean.getReminderMail()));
        tenant.setReminder_email(registrationBean.getReminderMail());
        tenant.setThankyou_email(registrationBean.getThankyouMail());

        CurrencyFormat cf = new CurrencyFormat();
        cf.setCurrencyFormatId(registrationBean.getCurrencyFormatId());
        tenant.setTenantCurrencyFormat(cf);

        DateFormat df = new DateFormat();
        df.setDateFormatId(registrationBean.getDateFormatId());
        tenant.setTenantDateFormat(df);

        tenant.setRegistration_date(registrationBean.createRegistrationDate());

        tenantService.addTenant(tenant);


        User user = new User();
        user.setName(registrationBean.getUserName());
        user.setAddress(registrationBean.getUserAddress());
        user.setUser_name(registrationBean.getUserLoginName());
        user.setDesignation(registrationBean.getUserDesignation());
        user.setPassword(registrationBean.getUserPassword());
        user.setEmail(registrationBean.getUserEmail());
        user.setContact_number(registrationBean.getUserContactNo());

        Role urole=new Role();
        urole.setRole_id(1);
        user.setUser_role(urole);


        userService.addUser(user);

        map.put("tenant_name", tenant.getTenant_name());
        return "tenant_registration_success";

    }


    @RequestMapping("/addANewTenant")
    public String showAddTenantPage(Map<String, Object> map)
    {
        /*map.put("item", new Item());
        map.put("itemList", itemService.listitems());*/
        return "add_tenant_details";
    }

}
@RequestMapping(value=“/registration”,method=RequestMethod.POST)
公共字符串addNewTenant(@ModelAttribute(“RegistrationBean”)RegistrationBean RegistrationBean,
BindingResult(结果,映射)
{
租户=新租户();
tenant.setTenant_名称(registrationBean.getTenantName());
tenant.setTenant_电子邮件(registrationBean.getTenantEmail());
setAddress(registrationBean.getTenantAddress());
//setrementer_email(Integer.parseInt(registrationBean.getrementermail());
setrementer_email(registrationBean.getrementermail());
setThankyou_email(registrationBean.getThankyouMail());
CurrencyFormat cf=新的CurrencyFormat();
cf.setCurrencyFormatId(registrationBean.getCurrencyFormatId());
承租人.货币格式(cf);
DateFormat df=新的DateFormat();
setDateFormatId(registrationBean.getDateFormatId());
承租人.数据格式(df);
tenant.setRegistration_date(registrationBean.createRegistrationDate());
租户服务。添加租户(租户);
用户=新用户();
user.setName(registrationBean.getUserName());
user.setAddress(registrationBean.getUserAddress());
user.setUser_名称(registrationBean.getUserLoginName());
user.setDesignation(registrationBean.getUserDesignation());
user.setPassword(registrationBean.getUserPassword());
user.setEmail(registrationBean.getUserEmail());
user.setContact_编号(registrationBean.getUserContactNo());
Role urole=新角色();
尿路石(1);
user.setUser_角色(urole);
userService.addUser(用户);
map.put(“tenant_name”,tenant.getTenant_name());
返回“租户注册成功”;
}
@请求映射(“/addANewTenant”)
公共字符串showAddTenantPage(地图)
{
/*map.put(“item”,newitem());
put(“itemList”,itemService.listitems())*/
返回“添加租户详细信息”;
}
}
这是我的JSP文件

<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Tanent Registration and Tanent Administrator Registration</title>
<style>
.error {
color: #ff0000;
font-style: italic;
}
</style>
</head>
<body>

Tanent注册和Tanent管理员注册
.错误{
颜色:#ff0000;
字体:斜体;
}
我将名为“RegistrationBean”的bean指定为modelAttribute

<h3>Tenant Registration</h3>
<form:form method="post" action="/MTInvoiceManagement/tenant/registration.html" modelAttribute="RegistrationBean">
<table align="left">
       <tr>
              <td>Tenant Name</td>
              <td><form:input path="tenantName" type="text" /></td>
              <td><form:errors path="tenantName" cssClass="error"></form:errors></td>
       </tr>

       <tr>
              <td>Tenant Email</td>
              <td><form:input path="tenantEmail" type="text" /></td>
              <td><form:errors path="tenantEmail" cssClass="error"/></td>

       </tr>
       <tr>
              <td>Tenant Address</td>
              <td><input name="tenantAddress" type="text" /></td>
              <td><form:errors path="tenantAddress" cssClass="error" ></form:errors></td>
       </tr>

       <tr>
              <td>Reminder Mail</td>
              <td>
                     <form:select path="reminderMail">                     
                     <form:option value="0" label="No"  />
                     <form:option value="1" label="Yes" />
                     </form:select>
              </td>
              <td><form:errors path="reminderMail" cssClass="errors"></form:errors></td>
       </tr>


       <tr>
              <td>Thank You Mail</td>
              <td>
                     <form:select path="thankyouMail">
                     <form:option value="0" label="No"></form:option>
                     <form:option value="1" label="Yes"></form:option>
                     </form:select>
              </td>
              <td> <form:errors path="thankyouMail" cssClass="errors"></form:errors>  </td>
       </tr>

       <tr>
              <td>Date Format</td>
              <td>
                     <form:select path="dateFormatId">
                     <form:option value="1" label="DD-MM-YY"></form:option>
                     <form:option value="2" label="MM-DD-YY"></form:option>
                     <form:option value="3" label="YYYY-MM-DD"></form:option>
                     </form:select>
              </td>
              <td><form:errors path="dateFormatId" cssClass="errors"></form:errors></td>
       </tr>

       <tr>
              <td>Currency Format</td>
              <td>
                     <form:select path="currencyFormatId">
                     <form:option value="1" label="$"></form:option>
                     <form:option value="2" label="£"></form:option>
                     <form:option value="3" label="¥"></form:option>
                     <form:option value="4" label="€"></form:option>
                     <form:option value="5" label="₨"></form:option>
                     </form:select>
              </td>
              <td><form:errors path="currencyFormatId" cssClass="errors" ></form:errors></td>
       </tr>

       <tr>
            <td> <h3> Tanent Administrator Details  </h3>  </td>
       </tr>

       <tr>
              <td>Tanent Admin Name</td>
              <td><form:input path="userName" type="text"/> </td>
              <td> <form:errors path ="userName" cssClass="errors"></form:errors> </td>
       </tr>

       <tr>
              <td>Tanent Admin User Login Name</td>              
              <td><form:input path="userLoginName" type="text"/> </td>
              <td> <form:errors path ="userLoginName" cssClass="errors"></form:errors> </td>
       </tr>
       <tr>
              <td>Tanent Admin User Password</td>              
              <td><form:input path="userPassword" type="password"/> </td>
              <td> <form:errors path ="userPassword" cssClass="errors"></form:errors> </td>
       </tr>
       <tr>
              <td>Tanent Admin User Email</td>              
              <td><form:input path="userEmail" type="text"/> </td>
              <td> <form:errors path ="userEmail" cssClass="errors"></form:errors> </td>
       </tr>
       <tr>
              <td>Tanent Admin User Contact No</td>              
              <td><form:input path="userContactNo" type="text"/> </td>
              <td> <form:errors path ="userContactNo" cssClass="errors"></form:errors> </td>
       </tr>
              <tr>
              <td>&nbsp;</td>
              <td>
                     <input name="Submit" type="submit" value="submit" />

              </td>
       </tr>
</table>
</form:form>

</body>
</html>
租户注册
承租人姓名
租户电子邮件
租户地址
提醒邮件
谢谢你的来信
日期格式
货币格式
Tanent管理员详细信息
Tanent管理员名称
TanentAdmin用户登录名
TANET管理员用户密码
TanentAdmin用户电子邮件
Tanent管理员用户联系号码

请帮帮我

在显示表单时,必须将RegistrationBean放入模型中。您可以使用与在公共字符串addNewTenant方法中相同的方法来执行此操作

 @RequestMapping("/addANewTenant")
    public String showAddTenantPage(Map<String, Object> map,@ModelAttribute("RegistrationBean")RegistrationBean registrationBean)
@ModelAttribute
public RegistrationBean getRegistrationBean() {

}