atjiu / pybbs

更实用的Java开发的社区(论坛),Better use of Java development community (forum)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

用最新的master代码遇到freemarker错误

zenghonghai opened this issue · comments

请求localhost:8080时报错:
2020-10-25 18:31:58 [XNIO-1 task-1] ERROR io.undertow.request - UT005023: Exception handling request to /
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:
==> site [in template "theme/default/layout/header.ftl" at line 3, column 44]


Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??


FTL stack trace ("~" means nesting-related):
- Failed at: ${site.name!} [in template "theme/default/layout/header.ftl" in macro "header" at line 3, column 42]
- Reached through: @Header page_tab=page_tab [in template "theme/default/layout/layout.ftl" in macro "html" at line 27, column 9]
- Reached through: @html page_title="首页" page_tab="index" [in template "theme/default/index.ftl" at line 2, column 1]

at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:503)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:590)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
at io.undertow.websockets.jsr.JsrWebSocketFilter.doFilter(JsrWebSocketFilter.java:173)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

@tomoya92 麻烦大佬看看这个问题

已解决。。。原来用curl才会出现这问题。。

relates to #142

When using a non-browser client (e.g. curl, HTTP client), add the following header to the request will solve the issue:

Accept: text/html