弹簧形式:输入标记错误

时间:2017-02-16 13:49:51

标签: java spring jsp spring-mvc

我有一个用于登录的简单表单。我正在为<form:input... /> x获取HTTP状态500

    <form:form modelAttribute="client" method="POST" id="login" action="/login" class="register-form">
        <form:input path="username" type="text" id="username" placeholder="username" />
        <form:input path="password" id="password" type="password" placeholder="password" />
        <button type="submit" value="Sign in">Sign in </button>>
        <p class="message">
            Not registered?
            <a href="#">Create an account</a>
        </p>
        <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
        <span>${success }</span>
    </form:form>

错误消息:message An exception occurred processing JSP page /WEB-INF/jsp/clogin.jsp at line 123。第123行是<form:input path="username" type="text" id="username" placeholder="username" />

错误日志:

  

Stacktrace:]带有根本原因java.lang.IllegalStateException:都没有   BindingResult也不是bean名称&#39;命令的明确目标对象。   可用作请求属性   org.springframework.web.servlet.support.BindStatus。(BindStatus.java:144)     在   org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:168)     在   org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:188)     在   org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:154)     在   org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:117)     在   org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:422)     在   org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:142)     在   org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:84)     在   org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:80)     在   org.apache.jsp.WEB_002dINF.jsp.clogin_jsp._jspx_meth_form_005finput_005f0(clogin_jsp.java:372)     在   org.apache.jsp.WEB_002dINF.jsp.clogin_jsp._jspx_meth_form_005fform_005f0(clogin_jsp.java:305)     在   org.apache.jsp.WEB_002dINF.jsp.clogin_jsp._jspService(clogin_jsp.java:248)     在org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)     在javax.servlet.http.HttpServlet.service(HttpServlet.java:729)at   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)     在   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)     在org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)     在javax.servlet.http.HttpServlet.service(HttpServlet.java:729)at   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)     在   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)     在   org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)     在   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)     在   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)     在   org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:715)     在   org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:460)     在   org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:385)     在   org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:311)     在   org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:209)     在   org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:267)     在   org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1225)     在   org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1012)     在   org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)     在   org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876)     在   org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)     在   org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)     在javax.servlet.http.HttpServlet.service(HttpServlet.java:622)at   org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)     在javax.servlet.http.HttpServlet.service(HttpServlet.java:729)at   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)     在   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)     在   org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)     在   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)     在   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)     在   org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:316)     在   org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126)     在   org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90)     在   org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330)     在   org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)     在   org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330)     在   org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:122)     在   org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330)     在   org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)     在   org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330)     在   org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:169)     在   org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330)     在   org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:48)     在   org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330)     在   org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:205)     在   org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330)     在   org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:120)     在   org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330)     在   org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:96)     在   org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)     在   org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330)     在   org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64)     在   org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)     在   org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330)     在   org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:53)     在   org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)     在   org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330)     在   org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:91)     在   org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330)     在   org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:213)     在   org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:176)     在   org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)     在   org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)     在   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)     在   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)     在   org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)     在   org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)     在   org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)     在   org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)     在   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)     在   org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)     在   org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)     在   org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)     在   org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:495)     在   org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)     在   org.apache.coyote.AbstractProtocol $ ConnectionHandler.process(AbstractProtocol.java:767)     在   org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1347)     在   org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)     在   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)     在   java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:617)     在   org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)     在java.lang.Thread.run(Thread.java:745)

我有什么遗失的东西吗?

1 个答案:

答案 0 :(得分:0)

在控制器中添加此ligne:

@ModelAttribute("client")
public Client client(){
  return new Client();
}

在你的jsp中

<form:form action="/login" model modelAttribute="client" ...>

最好的问候