CRUD機能を作成しているのですが、newとcreateとindexはできるみたいですが、edit show deleteができないです。
エラー文をみてみるとidがうまく取得できてないみたいなんですが下記のコードをそのまま書くと
メソッドの戻り値型をOptionai<Player>にしろという警告がでます。
ちなみにOptionai<Player>にするとエラーが出ます。
Java
1 public Player findOne(Player id) { 2 return playerRepository.findById(id); 3 }
エラー文です
Java
1This application has no explicit mapping for /error, so you are seeing this as a fallback. 2 3Sat Feb 20 17:06:30 JST 2021 4There was an unexpected error (type=Internal Server Error, status=500). 5An error happened during template parsing (template: "class path resource [templates/players/show.html]") 6org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/players/show.html]") 7 at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:241) 8 at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parseStandalone(AbstractMarkupTemplateParser.java:100) 9 at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:666) 10 at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098) 11 at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072) 12 at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:366) 13 at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:190) 14 at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1393) 15 at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1138) 16 at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1077) 17 at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:962) 18 at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) 19 at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) 20 at javax.servlet.http.HttpServlet.service(HttpServlet.java:626) 21 at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) 22 at javax.servlet.http.HttpServlet.service(HttpServlet.java:733) 23 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) 24 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) 25 at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) 26 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) 27 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) 28 at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) 29 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) 30 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) 31 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) 32 at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) 33 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) 34 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) 35 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) 36 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) 37 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) 38 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) 39 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) 40 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) 41 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) 42 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542) 43 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143) 44 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) 45 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) 46 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:346) 47 at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374) 48 at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) 49 at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:887) 50 at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1684) 51 at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 52 at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) 53 at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) 54 at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 55 at java.base/java.lang.Thread.run(Thread.java:834) 56Caused by: org.attoparser.ParseException: Exception evaluating SpringEL expression: "id" (template: "players/show" - line 13, col 14) 57 at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:393) 58 at org.attoparser.MarkupParser.parse(MarkupParser.java:257) 59 at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:230) 60 ... 48 more 61Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "id" (template: "players/show" - line 13, col 14) 62 at org.thymeleaf.spring5.expression.SPELVariableExpressionEvaluator.evaluate(SPELVariableExpressionEvaluator.java:292) 63 at org.thymeleaf.standard.expression.SelectionVariableExpression.executeSelectionVariableExpression(SelectionVariableExpression.java:158) 64 at org.thymeleaf.standard.expression.SimpleExpression.executeSimple(SimpleExpression.java:92) 65 at org.thymeleaf.standard.expression.Expression.execute(Expression.java:109) 66 at org.thymeleaf.standard.expression.Expression.execute(Expression.java:138) 67 at org.thymeleaf.standard.processor.AbstractStandardExpressionAttributeTagProcessor.doProcess(AbstractStandardExpressionAttributeTagProcessor.java:144) 68 at org.thymeleaf.processor.element.AbstractAttributeTagProcessor.doProcess(AbstractAttributeTagProcessor.java:74) 69 at org.thymeleaf.processor.element.AbstractElementTagProcessor.process(AbstractElementTagProcessor.java:95) 70 at org.thymeleaf.util.ProcessorConfigurationUtils$ElementTagProcessorWrapper.process(ProcessorConfigurationUtils.java:633) 71 at org.thymeleaf.engine.ProcessorTemplateHandler.handleOpenElement(ProcessorTemplateHandler.java:1314) 72 at org.thymeleaf.engine.TemplateHandlerAdapterMarkupHandler.handleOpenElementEnd(TemplateHandlerAdapterMarkupHandler.java:304) 73 at org.thymeleaf.templateparser.markup.InlinedOutputExpressionMarkupHandler$InlineMarkupAdapterPreProcessorHandler.handleOpenElementEnd(InlinedOutputExpressionMarkupHandler.java:278) 74 at org.thymeleaf.standard.inline.OutputExpressionInlinePreProcessorHandler.handleOpenElementEnd(OutputExpressionInlinePreProcessorHandler.java:186) 75 at org.thymeleaf.templateparser.markup.InlinedOutputExpressionMarkupHandler.handleOpenElementEnd(InlinedOutputExpressionMarkupHandler.java:124) 76 at org.attoparser.HtmlElement.handleOpenElementEnd(HtmlElement.java:109) 77 at org.attoparser.HtmlMarkupHandler.handleOpenElementEnd(HtmlMarkupHandler.java:297) 78 at org.attoparser.MarkupEventProcessorHandler.handleOpenElementEnd(MarkupEventProcessorHandler.java:402) 79 at org.attoparser.ParsingElementMarkupUtil.parseOpenElement(ParsingElementMarkupUtil.java:159) 80 at org.attoparser.MarkupParser.parseBuffer(MarkupParser.java:710) 81 at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:301) 82 ... 50 more 83Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'id' cannot be found on object of type 'java.util.Optional' - maybe not public or not valid? 84 at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:217) 85 at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:104) 86 at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:91) 87 at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:112) 88 at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:337) 89 at org.thymeleaf.spring5.expression.SPELVariableExpressionEvaluator.evaluate(SPELVariableExpressionEvaluator.java:265) 90 ... 69 more
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。