java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name "company" available as request attribute
今天在学spring mvc的时候,想做一个表单填写公司信息,然后添加到数据库中,但是spring标签一直报错,弄了很久,一直无解。
后来百度,谷歌好久,才想到在进入form表单页面之前,要有一个company对象才可以在表单的标签中识别出来,所以在controller里面
添加了如下内容:
@RequestMapping(value="/addCompany",method = RequestMethod.GET)
public ModelAndView initForm(ModelMap model){
Company company = new Company(); //用于转换到form表单的对象
return new ModelAndView("addCompany").addObject(company); //跳转到addCompany页面
}
addCompany页面的form表单如下:
<!-- 进入表单页面前必须创建一个company对象,把他放到context里面去,否则会报错 -->
<form:form commandName="company" modelAttribute="company" action="addCompany" method="post">
<fieldset>
<legend>Account Fields</legend>
<p>
<form:label path="name">Name</form:label> <!--这里对应company类中的name属性-->
<form:input path="name" /><form:errors path="name" />
</p>
<p>
<form:label path="password">Password</form:label> <!--这里对应company类中的name属性-->
<form:input path="password" /><form:errors path="password" />
</p>
<p>
<input id="create" type="submit" value="Create" />
</p>
</fieldset>
</form:form>
- 浏览: 41375 次
- 性别:
相关推荐
在进行JSR303验证的学习时,在进行表单跳转时出现了一个问题,解决方法很简单,但是困扰了我很长时间。 原创文章 1获赞 1访问量 16 关注 私信 展开阅读全文 作者:深衫老霖
so nor neither的用法总结PPT学习教案.pptx
In software engineering, mostly low-level languages were used for many years, which were closer to the computer machine code than to human language. In the 70s, Brian Kernighan and Dennis Ritchie ...
Neither...nor的用法小结.doc
work, we rigorously test these questions, and find that deformation stability in
Neither_Snow_Nor_Rain_Nor_MITM_ 红蓝对抗 安全对抗 业务安全 安全威胁 金融安全
Object-oriented Programming PacDrive 3 The information provided in this documentation contains general descriptions and/or technical characteristics of the performance of the products contained herein...
so nor neither的用法总结PPT教案.pptx
Neither host 'localhost.localdomain' nor 'localhost' could be looked up with /usr/bin/resolveip Please configure the 'hostname' command to return a correct hostname. 错误: 解决办法 1、查看/etc/...
easyOCR文字识别模型
Neither this book nor any part may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, microfilming, and recording, or by any information ...
notEmpty Evaluate the nested body content of this tag if the requested variable is neither null nor an empty string. notEqual Evaluate the nested body content of this tag if the requested variable is ...
Redistribution and use...Neither the name of the UNINOVA nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
- The System Uses Neither Unity UI nor IMGU, making it fast - Allows for a wide array of objects objects, even particle effects to be simulated in the radar. - Static minimaps, ideal for small ...
Neither this book nor any part may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, microfilming, and recording, or by any information ...
This specification and the material contained in it, as ... They have neither been developed, nor tested for non-automotive applications. The word AUTOSAR and the AUTOSAR logo are registered trademarks.
Neither this book nor any part may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, microfilming, and recording, or by any information ...
neither a general software engineering book which surveys all available methods nor a programming book about algorithms and data structures. Instead, we focus on a limited set of techniques and ...
Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has...