beetl2.7.5升级2.7.11异常

发布于 2021-12-02 17:24:58 字数 10846 浏览 868 评论 5

Spring Boot 1.4.4.RELEASE

问题如题,升级后报:

>>01:49:53:属性获取异常(ATTRIBUTE_INVALID):rescode 位于2行 资源:/htmltag/alert.html
属性访问出错
1|@if(isNotEmpty(result)){ 
2|@if(result.rescode=="0"){
3|<div class="am-alert am-alert-success" data-am-alert>
4|	<button type="button" class="am-close">&times;</button>
5|	<p>${result.resmsg!}</p>
6|</div>
  ========================
  调用栈:
  /htmltag/alert.html 行:2
  bs/property/form.html 行:4
  bs/property/edit.html 行:7
java.lang.RuntimeException: com.yuminsoft.common.Response cannot be cast to com.yuminsoft.common.Response如果采用优化引擎,会假定传给模板的变量是同一类型,如果不是,请使用directive dynamic 变量;来避免
	at org.beetl.core.misc.BeetlUtil.throwCastException(BeetlUtil.java:368)
	at org.beetl.core.statement.VarAttribute.evaluate(VarAttribute.java:63)
	at org.beetl.core.statement.VarRef.evaluate(VarRef.java:127)
	at org.beetl.core.statement.CompareExpression.evaluate(CompareExpression.java:65)
	at org.beetl.core.statement.IfStatement.execute(IfStatement.java:59)
	at org.beetl.core.statement.BlockStatement.execute(BlockStatement.java:68)
	at org.beetl.core.statement.IfStatement.execute(IfStatement.java:63)
	at org.beetl.core.statement.Program.execute(Program.java:70)
	at org.beetl.core.Template.renderTo(Template.java:137)
	at org.beetl.ext.tag.HTMLTagSupportWrapper.callHtmlTag(HTMLTagSupportWrapper.java:109)
	at org.beetl.ext.tag.HTMLTagSupportWrapper.render(HTMLTagSupportWrapper.java:68)
	at org.beetl.core.statement.TagStatement.runTag(TagStatement.java:108)
	at org.beetl.core.statement.TagStatement.execute(TagStatement.java:87)
	at org.beetl.core.statement.Program.execute(Program.java:70)
	at org.beetl.core.engine.FilterProgram.execute(FilterProgram.java:31)
	at org.beetl.core.Template.renderTo(Template.java:137)
	at org.beetl.ext.tag.IncludeTag.render(IncludeTag.java:76)
	at org.beetl.core.statement.TagStatement.runTag(TagStatement.java:108)
	at org.beetl.core.statement.TagStatement.execute(TagStatement.java:87)
	at org.beetl.core.statement.BlockStatement.execute(BlockStatement.java:68)
	at org.beetl.core.Tag.doBodyRender(Tag.java:60)
	at org.beetl.core.Tag.getBodyContent(Tag.java:69)
	at org.beetl.ext.tag.LayoutTag.render(LayoutTag.java:104)
	at org.beetl.core.statement.TagStatement.runTag(TagStatement.java:108)
	at org.beetl.core.statement.TagStatement.execute(TagStatement.java:87)
	at org.beetl.core.statement.Program.execute(Program.java:70)
	at org.beetl.core.Template.renderTo(Template.java:137)
	at org.beetl.core.Template.renderTo(Template.java:90)
	at org.beetl.ext.web.WebRender.render(WebRender.java:125)
	at org.beetl.ext.spring.BeetlSpringView.renderMergedTemplateModel(BeetlSpringView.java:123)
	at org.springframework.web.servlet.view.AbstractTemplateView.renderMergedOutputModel(AbstractTemplateView.java:167)
	at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
	at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1271)
	at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1037)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:980)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
	at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
	at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:105)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
	at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:105)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
	at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
	at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:106)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassCastException: com.yuminsoft.common.Response cannot be cast to com.yuminsoft.common.Response
	at com.yuminsoft.common.Response_rescode.value(Unknown Source)
	at org.beetl.core.statement.VarAttribute.evaluate(VarAttribute.java:61)
	... 84 more

alert.html

@if(isNotEmpty(result)){ 
@if(result.rescode=="0"){
<div class="am-alert am-alert-success" data-am-alert>
	<button type="button" class="am-close">&times;</button>
	<p>${result.resmsg!}</p>
</div>
<script type="text/javascript">
  var pageerror=true;
</script>
@}else{
<div class="am-alert am-alert-warning" data-am-alert>
	<button type="button" class="am-close">&times;</button>
	<p>${result.resmsg!}</p>
</div>
<script type="text/javascript">
  var pageerror=false;
</script>
@} }

Response.java

public class Response implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * 返回码(0、成功 1、失败)
	 */
	private String rescode;
	/**
	 * 失败说明
	 */
	private String resmsg;

	/**
	 * 业务返回值
	 */
	private Object result;

	public Response() {
	}
    //..set/get
}

updateController

	@PostMapping("bs/property/update")
	public String update(Model model, @Valid BsProperty t, BindingResult bindingResult, RedirectAttributes attr) {
		// 验证
		if (bindingResult.hasErrors()) {
			putModelError(model, bindingResult);
			model.addAttribute(WebConstant.FORM_MODEL, t);
			model.addAttribute(WebConstant.RESULT, Response.setError());// 失败提示标示
			return "bs/property/edit";
		}
		int i = service.update(t);
		if (i > 0) {
			// 成功
			attr.addFlashAttribute(WebConstant.RESULT, Response.setSuccess());// 成功提示标示
			return redirect("/bs/property/edit?id=" + t.getId());
		} else {
			model.addAttribute(WebConstant.FORM_MODEL, t);
			model.addAttribute(WebConstant.RESULT, Response.setError());
			return "bs/property/edit";
		}
	}

editController

	@GetMapping("bs/property/edit")
	public String edit(Model model, BsProperty t) {
		model.addAttribute(WebConstant.FORM_MODEL, service.get(t.getId()));
		return "bs/property/edit";
	}

看到有新版本就升级了,升级后异常,版本回退后正常。

debug截图

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

墨洒年华 2021-12-06 14:42:39

参照官网配置的

永不分离 2021-12-06 12:57:10

有个配置

檐上三寸雪 2021-12-06 08:54:43

看官网文档springboot集成

北笙凉宸 2021-12-06 07:15:05

这里忘记改了

坚持沉默 2021-12-06 05:31:30

spring boot集成需要注意的是要添加spring-devtools.properties文件,并配置如下选项

restart.include.beetl=/beetl-xxx.jar
restart.include.beetlsql=/beetlsql-xxx..jar

具体参考文档 http://ibeetl.com/guide/#beetl 

 

 

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文