Struts2+spring+mybatis导入freemarker后样式丢失

1、freemarker导入SSM项目后样式丢失原因


    <filter>
        <filter-name>struts2filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilterfilter-class>
    filter>
    <filter-mapping>
        <filter-name>struts2filter-name>
        <url-pattern>*.actionurl-pattern>
    filter-mapping>

以上是Struts2 的核心过滤器,拦截了js等静态资源

2、解决方案

1、在struts2.xml文件中加入


<constant name="struts.action.excludePattern" value="/public/.*?" />

2、在web.xml文件中加入

<servlet>
        <servlet-name>freemarkerservlet-name>
        <servlet-class>freemarker.ext.servlet.FreemarkerServletservlet-class>
        
        <init-param>
            
            <param-name>TemplatePathparam-name>
            <param-value>/param-value>
        init-param>
        <load-on-startup>1load-on-startup>
    servlet>
    <servlet-mapping>
        <servlet-name>freemarkerservlet-name>
        <url-pattern>*.ftlurl-pattern>
    servlet-mapping>

你可能感兴趣的:(模板-Freemarker)