beetl2.7.5升级2.7.11异常
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">×</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">×</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">×</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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
参照官网配置的
有个配置
看官网文档springboot集成
这里忘记改了
spring boot集成需要注意的是要添加spring-devtools.properties文件,并配置如下选项
具体参考文档 http://ibeetl.com/guide/#beetl