• struts2与FreeMarker 简单配置实现


    核心包:(下载地址:http://struts.apache.org/download.cgi#struts231-SNAPSHOT

    asm-3.1.jar

    asm-commons-3.1.jar

    commons-fileupload-1.2.2.jar

    commons-io-2.0.1.jar

    commons-lang-2.5.jar

    commons-logging-1.1.1.jar

    freemarker-2.3.16.jar

    javassist-3.11.0.GA.jar

    log4j-1.2.15.jar  //日志

    ognl-3.0.1.jar

    struts2-convention-plugin-2.2.3.1.jar //注解

    struts2-core-2.2.3.1.jar

    xwork-core-2.2.3.1.jar


    web.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5"
    xmlns
    ="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi
    ="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation
    ="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    >

    <!-- Struts2 filter -->
    <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>*.htm</url-pattern>
    </filter-mapping>

    <servlet>
    <servlet-name>JspSupportservlet</servlet-name>
    <servlet-class>org.apache.struts2.views.JspSupportServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>JspSupportservlet</servlet-name>
    <url-pattern>*.ftl</url-pattern>
    </servlet-mapping>

    <!-- 定义错误页面 -->
    <error-page>
    <error-code>403</error-code>
    <location>/error/error1.htm</location>
    </error-page>
    <error-page>
    <error-code>404</error-code>
    <location>/error/error1.htm</location>
    </error-page>
    <error-page>
    <error-code>500</error-code>
    <location>/error/error1.htm</location>
    </error-page>

    <welcome-file-list>
    <welcome-file>index.htm</welcome-file>
    </welcome-file-list>

    </web-app>

    struts.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd" >

    <struts>
    <constant name="struts.devMode" value="true"/>
    <constant name="struts.locale" value="zh_CN"/>
    <constant name="struts.i18n.encoding" value="utf-8"/>
    <constant name="struts.action.extension" value="htm"/>
    <constant name="struts.convention.result.path" value="/WEB-INF/content/"></constant>
    <constant name="struts.multipart.saveDir" value="temp"></constant>
    <constant name="struts.ui.theme" value="simple"/>
    <constant name="struts.multipart.maxSize" value="1000000000"/>
    <constant name="struts.custom.i18n.resources" value="messages"/>
    <constant name="struts.ognl.allowStaticMethodAccess" value="true"/>

    <!-- 没找到页面 -->
    <package name="default" extends="struts-default">
    <default-action-ref name="notFound"/>
    <action name="notFound">
    <result type="redirect">/error/error1.htm</result>
    </action>
    </package>

    </struts>

    freemarker.properties

    locale=zh_CN
    default_encoding=UTF-8
    number_format=#
    date_format=yyyy-MM-dd
    time_format=HH:mm:ss
    datetime_format=yyyy-MM-dd HH:mm:ss
    template_update_delay=0
    classic_compatible=true
  • 相关阅读:
    Java并发
    JS的强制类型转换
    JS的原生函数
    JS的类型和值
    解决Oracle临时表空间占满的问题
    nginx location匹配规则
    java.util.ConcurrentModificationException 解决办法
    SQL优化三板斧:精简之道、驱动为王、集合为本
    一次非典型SQL优化:如何通过业务逻辑优化另辟蹊径?
    一次耐人寻味的SQL优化:除了SQL改写,还要考虑什么?
  • 原文地址:https://www.cnblogs.com/linyu/p/2238940.html
Copyright © 2020-2023  润新知