Struts2学习笔记

来源:互联网 发布:windows获取本地时间 编辑:程序博客网 时间:2024/06/05 17:45

Struts2原理

这里写图片描述

Struts2核心配置文件

  1. web.xml 配置过滤器
 <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>/*</url-pattern>    </filter-mapping>
  1. struts.xml
<package name="default" namespace="/" extends="struts-default">        <default-action-ref name="index" />        <global-results>            <result name="error">/WEB-INF/jsp/error.jsp</result>        </global-results>        <global-exception-mappings>            <exception-mapping exception="java.lang.Exception" result="error"/>        </global-exception-mappings>        <action name="index">            <result type="redirectAction">                <param name="actionName">HelloWorld</param>                <param name="namespace">/example</param>            </result>        </action>    </package>
  1. struts.properties struts2的全局属性文件
0 0