zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    啥是IOC ?啥是DI ?
    Spring是什么?
    Javaweb实训-宠物医院-社区宠物医院登陆页面
    Javaweb实训-宠物医院-社区宠物医院的页面样式
    Bootstrap基础学习(二)
    Bootstrap基础学习(一)
    常用的几种清除float浮动的方法
    jquery的each遍历方法
    正则总结RegExp
    OpenWrt编译到底脚本
  • 原文地址:https://www.cnblogs.com/linyu/p/2238940.html
Copyright © 2011-2022 走看看