Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复代码生成模块中:因手动删除 ruoyi_sys_menu 历史菜单数据不干净,导致点击“上级菜单”出现500的错误 #225

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

leceshide
Copy link

修复代码生成模块中:因上一次手动删除 ruoyi_sys_menu 历史菜单数据,而该表的“上级菜单”配置修改并未同步清空,再次点击“上级菜单”时出现500的错误。

复现步骤:
1)用户第一次选择目标表并生成对应的代码和菜单SQL(配置了 上级菜单 这一项), 并且执行菜单SQL完成
2)用户重启服务后发现菜单位置不符合要求,遂删除自动生成的相关代码和菜单SQL,但此时用户并未删除该表的配置信息(尤其是:)
3)用户选择重新生成代码,当点击“上级菜单”这一步时报错,错误如下:

21:10:36.555 [http-nio-10000-exec-25] ERROR o.t.TemplateEngine - [process,1136] - [THYMELEAF][http-nio-10000-exec-25] Exception processing template "system/menu/tree": An error happened during template parsing (template: "class path resource [templates/system/menu/tree.html]") org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/system/menu/tree.html]") at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:241) at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parseStandalone(AbstractMarkupTemplateParser.java:100) …… at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) Caused by: org.attoparser.ParseException: Exception evaluating SpringEL expression: "menu.menuId" (template: "system/menu/tree" - line 12, col 54) at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:393) at org.attoparser.MarkupParser.parse(MarkupParser.java:257) at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:230) ... 84 common frames omitted Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "menu.menuId" (template: "system/menu/tree" - line 12, col 54) at org.thymeleaf.spring5.expression.SPELVariableExpressionEvaluator.evaluate(SPELVariableExpressionEvaluator.java:292) …… at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:301) ... 86 common frames omitted Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'menuId' cannot be found on null at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:219) ……org.thymeleaf.spring5.expression.SPELVariableExpressionEvaluator.evaluate(SPELVariableExpressionEvaluator.java:265) ... 105 common frames omitted 21:10:36.744 [http-nio-10000-exec-25] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - [log,175] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/system/menu/tree.html]")] with root cause org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'menuId' cannot be found on null at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:219) ……

111

经过分析,发现是点击“上级菜单”时,调用历史设置的菜单ID(2007) 加载后台对应的数据(HTTP接口:system/menu/selectMenuTree/2007 ),而 menuId= 2007 已被手动删除,所以导致SpringEL表达式异常,需要对如下代码做防御性编程:
<input id="treeId" name="treeId" type="hidden" th:value="${menu.menuId}"/> <input id="treeName" name="treeName" type="hidden" th:value="${menu.menuName}"/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant