BindingResult和bean名称'userForm'的普通目标对象都不可用作请求属性

时间:2017-03-14 06:47:02

标签: spring model-view-controller

I keep having the error as mention above and i cannot figure it out what is the reason behind even refer to the example in stackoverflow. It cannot map to the parameter in my controller

这是我的控制器和指向此处的modelattribute,ch8ssoformbean是jsp中定义的参数的java bean

**Java Controller**

@Controller
public class Ch8SSOController{
    private static final Logger LOG = LoggerFactory.getLogger(Ch8SSOController.class);
    private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");


    @RequestMapping(value = "/subscribe", method = RequestMethod.POST)
    private String subscribe(@ModelAttribute("userForm") Ch8SSOFormBean ssoBean) throws IOException, ParseException {
  //i had remove the implementation
        return null;
    }

我的jsp用于显示布局,我使用弹簧形式进行布局

**JSP View**

<%@ page contentType="text/html; charset=UTF-8" %>
<%@ include file="/WEB-INF/includes/taglibs.jinc" %>
<%--@elvariable id="self" type="com.ufinity.mediacorp.contentbeans.MCContainer"--%>
<%--@elvariable id="cmpage" type="com.coremedia.starterkit.common.contentbeans.Page"--%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<c:set var="ssoServerUrl" value="${sk:setting(cmpage.navigation, 'mc.sso.server.url')}"/>

<script type="text/javascript">
  window.mcaAsyncInit = function () {
    MCA.init({
    });
  };

  (function (d) {
    var js, id = 'mcajssdk', ref = d.getElementsByTagName("script")[0];
    if (d.getElementById(id)) { return; }
    js = d.createElement("script"); js.id = id; js.async = true;
    js.src = "${ssoServerUrl}";
    ref.parentNode.insertBefore(js, ref);
  }(document));
</script>

<div class="widget text newsletter">
  <h3 class="wg-title"><span class="fmc fmc-envelope"></span> <c:out value="${self.title}" /></h3>
  <div class="wg-content">
  <form:form method="post" modelAttribute="userForm" action="subscribe" >
    <form:input type="text" path="email" placeholder="Email Address" /></br>
    <label><b><fmt:message key="newsletter.gender" /></b>
     <form:input type="radio" path="gender" value="male"/><fmt:message key="newsletter.gender.male" />
        <form:input type="radio" path="gender" value="female"/><fmt:message key="newsletter.gender.female" /></label>
   </br>
    <b><fmt:message key="newsletter.age" /></b><form:input type="text" path="age" style="width:30%"/>
    <button type="submit" style="" onclick="location.href='/subscribe'" ><fmt:message key="newsletter.signup" /></button>
    </form:form>
  </div>
</div>

0 个答案:

没有答案