首页 文章

在Spring项目中使用@ModelAttribute时出错SpringInputGeneralFieldAttrProcessor

提问于
浏览
1

我正在尝试使用表单更新用户名 . 问题是,当我使用@ModelAttribute时,我得到以下错误:

执行处理器'org.thymeleaf.spring4.processor.attr.SpringInputGeneralFieldAttrProcessor'时出错(帐号:79)

Full error information from IDE:

2017-12-30 09:03:16.082 ERROR 6536 --- [nio-8080-exec-7] oaccC [ . [ . [/] . [dispatcherServlet]:Servlet中的Servlet.service()[dispatcherServlet] with path []抛出异常[请求处理失败;嵌套异常是org.thymeleaf.exceptions.TemplateProcessingException:执行处理器'org.thymeleaf.spring4.processor.attr.SpringInputGeneralFieldAttrProcessor'(帐号:79)]时出错,根本原因java.lang.IllegalStateException:既不是BindingResult也不是普通的目标对象for bean name'user'可在org.springframework.web.servlet.support.BindStatus中作为请求属性使用 . (BindStatus.java:144)〜[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE]在org.thymeleaf.spring4.util.FieldUtils.getBindStatusFromParsedExpression(FieldUtils.java:401)〜[thymeleaf-spring4-2.1.6.RELEASE.jar:2.1.6.RELEASE] org.thymeleaf.spring4.util.FieldUtils . 在org.thymeleaf.spring4.util.FieldUtils.getBindStatus(FieldUtils.java:294)〜[thymeleaf]的getBindStatus(FieldUtils.java:328)〜[thymeleaf-spring4-2.1.6.RELEASE.jar:2.1.6.RELEASE] -spring4-2.1.6.RELEASE.jar:2.1.6.RELEASE] at org.thymeleaf.spring4.processor.attr.AbstractSpringFieldAttrProcessor.processAttribute(AbstractSpringFieldAttrProces sor.java:98)〜[thymeleaf-spring4-2.1.6.RELEASE.jar:2.1.6.RELEASE] org.thymeleaf.processor.attr.AbstractAttrProcessor.doProcess(AbstractAttrProcessor.java:87)〜[thymeleaf-2.1 .6.RELEASE.jar:2.1.6.RELEASE] org.thymeleaf.processor.AbstractProcessor.process(AbstractProcessor.java:212)〜[thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] at org .thymeleaf.dom.Node.applyNextProcessor(Node.java:1017)〜[thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] at org.thymeleaf.dom.Node.processNode(Node.java:972) 〜[thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)~ [thymeleaf-2.1.6.RELEASE.jar:2.1.6 .RELEASE] org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)〜[thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] org.thymeleaf.dom.Node.processNode(Node .java:990)〜[thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)~ [thymeleaf-2.1.6.RELEASE . jar:2.1.6.RELEASE] at org orthy.lemeleaf.dom.Node.processNode上的.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)~ [thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE](Node.java:990) 〜[thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)~ [thymeleaf-2.1.6.RELEASE.jar:2.1.6 .RELEASE] org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)〜[thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] org.thymeleaf.dom.Node.processNode(Node .java:990)〜[thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)~ [thymeleaf-2.1.6.RELEASE . jar:2.1.6.RELEASE]在org.thymeleaf.dom的org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)〜[thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] . Node.processNode(Node.java:990)~ [thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] atg.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)~ [thymeleaf-2.1 .6.RELEASE.jar:2.1 . 6.RELEASE] org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)〜[thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] at org.thymeleaf.dom.Node.processNode( Node.java:990)~ [thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] atg.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)~ [thymeleaf-2.1.6.RELEASE .jar:2.1.6.RELEASE]在org.thymeleaf.dom的org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)〜[thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] .Node.processNode(Node.java:990)~ [thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] atg.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)~ [thymeleaf- 2.1.6.RELEASE.jar:2.1.6.RELEASE] at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)~ [thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] at org.thymeleaf.dom.Node.processNode(Node.java:990)〜[thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695 )〜[thymeleaf-2.1.6 .RELEASE.jar:2.1.6.RELEASE]在org.thymeleaf的org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)〜[thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] .dom.Node.processNode(Node.java:990)~ [thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] atg.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)~ [ thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] atorg.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)〜[thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] org.thymeleaf.dom.Node.processNode(Node.java:990 )〜[thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)~ [thymeleaf-2.1.6.RELEASE.jar:2.1 . 6.RELEASE] org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)〜[thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] at org.thymeleaf.dom.Node.processNode( Node.java:990)~ [thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] org.thymeleaf.dom.Document.process(Document.java:93)〜[thymeleaf-2.1.6.RELEASE .jar:2.1.6.RELEASE] org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1155)〜[thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] org.thymeleaf.TemplateEngine.process (TemplateEngine.java:1060)〜[thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1011)〜[thymeleaf-2.1.6.RELEASE . jar:2.1.6.RELEASE]在org.thy meleaf.spring4.view.ThymeleafView.renderFragment(ThymeleafView.java:335)~ [thymeleaf-spring4-2.1.6.RELEASE.jar:2.1.6.RELEASE] org.thymeleaf.spring4.view.ThymeleafView.render(ThymeleafView) .java:190)〜[thymeleaf-spring4-2.1.6.RELEASE.jar:2.1.6.RELEASE] org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1286)〜[spring-webmvc- 4.3.13.RELEASE.jar:4.3.13.RELEASE] at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1041)〜[spring-webmvc-4.3.13.RELEASE.jar:4.3.13 .RELEASE] org.springframework.web.serv宿舍上的org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:984)〜[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE] org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)中的.DispatcherServlet.doService(DispatcherServlet.java:901)~ [spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE] org.springframewor上的〜[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE] k.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)〜[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE],位于javax.servlet.http.HttpServlet.service(HttpServlet.java) :635)〜[tomcat-embed-core-8.5.23.jar:8.5.23]在org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)〜[spring-webmvc-4.3.13 . RELEASE.jar:4.3.13.RELEASE]在org.apache的javax.servlet.http.HttpServlet.service(HttpServlet.java:742)〜[tomcat-embed-core-8.5.23.jar:8.5.23] . catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)〜[tomcat-embed-core-8.5.23.jar:8.5.23] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166 )〜[tomcat-embed-core-8.5.23.jar:8.5.23]在org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)〜[tomcat-embed-websocket-8.5 . 23.jar:8.5.23]在org.apac的org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)〜[tomcat-embed-core-8.5.23.jar:8.5.23] he.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)~ [tomcat-embed-core-8.5.23.jar:8.5.23] at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy) .java:317)〜[spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE] org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127) 〜[spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE] org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)〜[spring-security -web-4.2.3.RELEASE.jar:4.2.3.RELEASE]在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:331)〜[spring-security-web-4.2.3 . RELEASE.jar:4.2.3.RELEASE]在org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)〜[spring-security-web-4.2.3.RELEASE.jar:4.2.3 .RELEASE]在org.springframework.secu org.springframework.security.web.session.SessionManagementFilter上的rity.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:331)~ [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE] .doFilter(SessionManagementFilter.java:137)〜[spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java: 331)〜[spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE] org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)~ [spring-security -web-4.2.3.RELEASE.jar:4.2.3.RELEASE]在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:331)〜[spring-security-web-4.2.3 . RELEASE.jar:4.2.3.RELEASE] at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)〜[spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:331)〜[spring-security-web -4.2.3.RELEASE.jar:4.2.3.RELEASE]在org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)〜[spring-security-web-4.2.3.RELEASE . jar:4.2.3.RELEASE]在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:331)〜[spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE在org.springframework.security的org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200)〜[spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE] org.springframework.security.web.authentication.logout中的.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:331)〜[spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE] . LogoutFilter.doFilter(登录outFilter.java:116)〜[spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:331)〜 [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]在org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64)〜[spring-security-web- 4.2.3.RELEASE.jar:4.2.3.RELEASE]在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)〜[spring-web-4.3.13.RELEASE.jar:4.3.13 .RELEASE] org.springframework上的org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:331)~ [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE] org.springframework.security.web.FilterChainProxy $ .security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)〜[spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE] VirtualFilterChain.doFilter(FilterChainProxy.java:331)〜[ spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE] at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)〜[spring-security -web-4.2.3.RELEASE.jar:4.2.3.RELEASE]在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)〜[spring-web-4.3.13.RELEASE.jar: 4.3.13.RELEASE]在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:331)〜[spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE] at at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)〜[spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE] org.springframework.security.web.FilterChainProxy .doFilter(FilterChainProxy.java:177)〜[spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE] org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:347) 〜[ spring 网络4.3.13.RELEASE.jar:4.3.1 3.RELEASE]在org.apache.catalina的org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:263)〜[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE] . core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)~ [tomcat-embed-core-8.5.23.jar:8.5.23] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)~ [tomcat-embed-core-8.5.23.jar:8.5.23]在org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)〜[spring-web-4.3.13.RELEASE.jar: 4.3.13.RELEASE]在org.apache的org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)〜[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE] . catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)〜[tomcat-embed-core-8.5.23.jar:8.5.23] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166在组织中~~ [tomcat-embed-core-8.5.23.jar:8.5.23] . orframe.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter)中的springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:108)〜[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE] .java:107)〜[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE] org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)~ [tomcat-embed- core-8.5.23.jar:8.5.23] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)~ [tomcat-embed-core-8.5.23.jar:8.5.23] at at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)〜[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE] org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:107)〜[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE] org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)〜[tomcat-embed-core-8.5.23.jar:8.5.23]在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)〜[tomcat-embed-core-8.5.23.jar :8.5.23]在org.springframework.web的org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)〜[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE] .filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)〜[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java: 193)〜[tomcat-embed-core-8.5.23.jar:8.5.23] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)~ [tomcat-embed-core-8.5.23 .jar:8.5.23]在org.apache.catalina的org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)〜[tomcat-embed-core-8.5.23.jar:8.5.23]组织中的.core.StandardContextValve.invoke(StandardContextValve.java:96)[tomcat-embed-core-8.5.23.jar:8.5.23] . apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)[tomcat-embed-core-8.5.23.jar:8.5.23] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java: 140)[tomcat-embed-core-8.5.23.jar:8.5.23] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)[tomcat-embed-core-8.5.23.jar :8.5.23] org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)[tomcat-embed-core-8.5.23.jar:8.5.23] org.apache.catalina.connector . CoyoteAdapter.service(CoyoteAdapter.java:342)[tomcat-embed-core-8.5.23.jar:8.5.23]在org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)[tomcat-embed -core-8.5.23.jar:8.5.23] org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)[tomcat-embed-core-8.5.23.jar:8.5.23] at org . apache.coyote.AbstractProtocol $ ConnectionHandler.process(AbstractProtocol.java:868)[tomcat-embed-core-8.5.23.jar:8.5.23] at org.apache.tomcat.util.net.NioEnd在org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)中指向$ SocketProcessor.doRun(NioEndpoint.java:1459)[tomcat-embed-core-8.5.23.jar:8.5.23] [tomcat-embed-core-8.5.23.jar:8.5.23] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)[na:1.8.0_152] at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:624)[na:1.8.0_152] at org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)[tomcat-embed-core-8.5.23 .jar:8.5.23] at java.lang.Thread.run(Thread.java:748)[na:1.8.0_152]

Account Controller class:

@Controller
public class AccountController {

    @Autowired
    private UserService userService;

    @GetMapping("/account")
    public ModelAndView adminPage(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("account");
        //modelAndView.addObject("users", userService.getAllUsers());
        return modelAndView;
    }


    @PutMapping("/renameUsername")
    public ModelAndView renameUserName(@ModelAttribute("user") User newUserName) {
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        String currentUser = auth.getName();
        userService.changeUsername(currentUser, newUserName);
        return new ModelAndView("account");
    }

Model User class:

@Entity
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
@ToString
public class User {
    @Id
    private String logonName;
    private String firstName;
    private String lastName;
    @JsonIgnore
    private String password;
    private String recoveryQuestion;
    @JsonIgnore
    private String recoveryAnswer;

}

User service method responsible for username change:

public  void changeUsername(String oldUserName, User newUserName) {
    User user = userRepository.findOne(oldUserName);
    user.setLogonName(newUserName.getLogonName());
    userRepository.save(user);
}

account.html code snippet:

<div class="jumbotron">
  <form th:action="@{/renameUsername}" th:method="put" th:object="${user}">
    <dl class="row">
      <dt class="col-sm-5">
<p>Change username:</p>
<p class="description">Enter your username, which you will use to login</p>
</dt>
      <dd class="col-sm-7">
        <p>
          <label for="inputUser" class="sr-only">username</label>
          <input type="text" id="inputUser" class="form-control" name="logonName" th:field="*{logonName}" placeholder="Username" />
        </p>
        <p>
          <button type="submit" class="btn btn-sm btn-warning">Update username</button>a
        </p>
      </dd>
    </dl>
  </form>
</div>

我试图使用文章来解决问题,在这些文章中,报告类似问题但解决方案不起作用的人 . 大多数情况下,变量/型号名称中存在拼写错误 . 我检查了这个,但我仍然遇到这个问题 .

有什么建议我收到此错误?

1 回答

  • 0

    在你的代码 /modelAndView.addObject("users", userService.getAllUsers()); . 但在你看来 <form th:action="@{/renameUsername}" th:method="put" th:object="${user}">

    users 更改为 user .

相关问题