我想将https://github.com/Serhioromano/bootstrap-calendar集成到Spring应用程序中。
因此,我按照描述的方式设置了所有的东西--将tmpls文件放在/tmpls文件夹中,并在配置中添加了下面一行,因此不需要显式控制器。
<mvc:view-controller path="/tmpls/*"/>
我得到以下错误:
GET http://localhost:8080/*/tmpls/month.html 500 (Internal Server Error)
那是因为:
org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 3
ERROR org.thymeleaf.TemplateEngine - [THYMELEAF][tomcat-http--31] Exception processing template "tmpls/month": Exception parsing document: template="tmpls/month", line 2 - column 3
根据templateEngine,在这些模板中使用了大量无效字符。
Invalid character used in text string ( <% _.each(days_name, function(name){ %> ).
我能做些什么使这些模板在我的应用程序中工作吗?
我真的迷路了,我需要一个提示。我愿意帮忙,特克斯。
发布于 2015-11-16 12:36:31
我现在想出了一个解决方案:
我将tmpls文件夹添加到我的应用程序中:
WEB-INF/thymeleaf/tmpls
我在配置中添加了折叠行,因此不需要显式控制器。
<mvc:view-controller path="/tmpls/*"/>
我添加了第二个基于JSP的Servlet和JSPResolver:
web.xml:
<servlet>
<servlet-name>JSP_Servlet</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/spring/jsp-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JSP_Servlet</servlet-name>
<url-pattern>/jsp/*</url-pattern>
</servlet-mapping>
jsp-config.xml:
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/thymeleaf/" />
<property name="suffix" value=".html" />
</bean>
然后在前面:
<script type="text/javascript">
$(document).ready(function() {
var calendar = $("#calendar").calendar(
{
tmpl_path: "../jsp/tmpls/",
events_source: function () { return []; }
});
});
</script>
模板显示正确。行动似乎很好。
我不知道是否有一个更干净、更简单的解决方案,因为链接servlet可能不是最好的主意。对我来说现在没事了。
https://stackoverflow.com/questions/33731400
复制相似问题