繁体   English   中英

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

[英]Error SpringInputGeneralFieldAttrProcessor when using @ModelAttribute in Spring project

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

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

来自IDE的完整错误信息:

2017-12-30 09:03:16.082错误6536-[nio-8080-exec-7] oaccC [。[。[/]。[dispatcherServlet]:Servlet [dispatcherServlet]的Servlet.service()路径[]引发异常[请求处理失败; 嵌套的异常是org.thymeleaf.exceptions.TemplateProcessingException:执行处理器“ org.thymeleaf.spring4.processor.attr.SpringInputGeneralFieldAttrProcessor”(帐户:79)时发生错误,其根本原因是

java.lang.IllegalStateException:在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.getBindStatus(FieldUtils.java:328)〜[thymeleaf-spring4-2.1.6.RELEASE.jar:2.1.6.RELEASE]在org.thymeleaf.spring4.util.FieldUtils .getBindStatus(FieldUtils.java:294)〜[thymeleaf-spring4-2.1.6.RELEASE.jar:2.1.6.RELEASE]在org.thymeleaf.spring4.processor.attr.AbstractSpringFieldAttrProcessor.processAttribute(AbstractSpringFieldAttrProcessor.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.thy meleaf.processor.AbstractProcessor.process(AbstractProcessor.java:212)〜[thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE]在org.thymeleaf.dom.Node.applyNextProcessor(Node.java:1017)〜 org.thymeleaf.dom.Node.processNode(Node.java:972)的[thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE]〜[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.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.doAdditionalProcess(NestableNode.java:668)上的org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)〜[thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE] )〜[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.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.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]在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]在org.thymeleaf.dom.Node.processNode(Node.java :990)〜[thymeleaf-2 org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)的[.1.6.RELEASE.jar:2.1.6.RELEASE](org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)〜 .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.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.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- org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1011)的[2.1.6.RELEASE.jar:2.1.6.RELEASE]〜org.org的[thymeleaf-2.1.6.RELEASE.jar:2.1.6.RELEASE]。 thymeleaf.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],位于org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1041)〜[spring-webmvc-4.3.13.RELEASE.jar:4.3.13 [RELEASE],位于org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:984)〜[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE],位于org.springframework.web.servlet .DispatcherServlet.doService(DispatcherServlet.java:901)〜[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE]在org.sprin gorgwork.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)〜[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE] at org.springframework.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- org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)的[8.5.23.jar:8.5.23]〜[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE] javax.servlet.http.HttpServlet.service(HttpServlet.java:742)〜[tomcat-embed-core-8.5.23.jar:8.5.23]在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java :231)〜[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.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)〜[tomcat-embed-websocket-8.5.23.jar:8.5.2 3],位于org.apache.catalina.core.ApplicationFilterChain的org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)〜[tomcat-embed-core-8.5.23.jar:8.5.23]。 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。释放]在org.springframework.security.web.access.E xceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)〜[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.session.SessionManagementFilter.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.org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:331)〜[spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]。 springframework.security.w eb.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.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200)〜[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.logout.LogoutFilter.doFilter(LogoutFilter.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.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy。 java:331)〜[spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]在org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)〜[spring - 安全 - 网络4.2.3.RELEASE.jar:4.2.3.RELEAS E]位于org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:331)〜[spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]。 org.springframework.web.filter上的security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)〜[spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE] .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]在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-web-4.3.13.RELEASE.jar:4.3.13.RELEASE] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:263 )〜[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。 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)的[23.jar:8.5.23]〜org.springframework的[tomcat-embed-core-8.5.23.jar:8.5.23]。 web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)〜[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.cor e.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)〜[tomcat-embed-core-8.5.23.jar:8.5.23]在org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:108)〜 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)上的[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]〜[spring-web-4.3.13.RELEASE。 jar:4.3.13.RELEASE]在org.apache.org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)〜[tomcat-embed-core-8.5.23.jar:8.5.23]。 catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)〜[tomcat-embed-core-8.5.23.jar:8.5.23]在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.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)〜[spring-web-4.3.13.RELEASE.jar: org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)的[4.3.13.RELEASE]〜org.apache的[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]在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)〜[tomcat-embed-core-8.5.23。 jar:8.5.23]位于org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:96)[tomcat-embed-core-8.5.23.jar:8.5.23] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)[tomcat-embed-core -8.5.23.jar:8.5.23]在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)[org.tomcat-embed-core-8.5.23.jar:8.5.23]。 apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)[tomcat-embed-core-8.5.23.jar:8.5.23] at 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]在org.apache.coyote.AbstractProtocol $ ConnectionHandler.process(AbstractProtocol.java:8 68)[tomcat-embed-core-8.5.23.jar:8.5.23]在org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1459)[tomcat-embed-core-8.5 .23.jar:8.5.23],位于org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)[tomcat-embed-core-8.5.23.jar:8.5.23]。 org.org处util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)[na:1.8.0_152] [na:1.8.0_152] 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]

客户控制器类:

@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");
    }

模型用户类别:

@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;

}

负责用户名更改的用户服务方法:

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

account.html代码段:

 <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> 

我尝试使用文章来解决此问题,在该文章中,人们报告了类似的问题,但解决方案却不起作用。 多数情况下,变量/模型名称中的错字有问题。 我检查了这个,但仍然遇到这个问题。

有什么建议为什么我会出现此错误?

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

更改usersuser

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM