Struts2核心文件

一、web.xml

任何MVC框架与web应用整合都需要使用web.xml文件,只有配置在web.xml文件中的Servlet才会被加载执行。对于Struts2而言,需要加载StrutsPrepareAndExecuteFilter,只要web应用加载StrutsPrepareAndExecuteFilter,StrutsPrepareAndExecuteFilter就会加载Struts2框架。

二、struts.xml

struts.xml是struts2的核心配置文件,主要负责管理应用中的Action映射,以及该Action包含的result定义等。包含的内容有:
1、全局属性;
2、用户请求和相应Action之间的对应关系;
3、Action可能用到的参数和返回结果;
4、各种拦截器的配置。

该文件主要标签的含义如下:

    
    <include file="struts-default.xml">include>

    
    <package name="default" namespace="/" extends="struts-default">

        
        <action name="helloworld" class="action.HelloWorldAction">

            
            <result name="success" type="dispatcher">/result.jspresult>
        action>
    package>

三、struts.properties

此文件是struts2的全局属性文件,自动加载,包含很多的key-value对,该文件可以使用constant完全配置在struts.xml中。

你可能感兴趣的:(struts学习)