Strust配置文件详解!!!

解决方案 »

  1.   

    网上多了去了,认真找找吧。不过,我把我认为几个比较重要的先说一下哈。
    struts2相关的配置文件有web.xml,struts.xml
    struts.xml:配置包含result/view类型,action映射、拦截器等的struts2的主要配置文件
    web.xml包含所有必须的框架组件的web部署描述符。
    具体的你使用一下就知道是怎么回事了。
      

  2.   

    web配置示范:<?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app id="WebApp_ID">
    <display-name>HelloStruts</display-name>
    <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>

    <listener>
    <listener-class>
    org.springframework.web.context.ContextLoaderListener
    </listener-class>
    </listener>
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:com/ioc/test6/beans.xml</param-value>
    </context-param>

    <servlet>
             <servlet-name>action</servlet-name>
             <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
             <load-on-startup>1</load-on-startup>
             <init-param>
                 <param-name>config</param-name>
                 <param-value>/WEB-INF/struts-config.xml</param-value>
             </init-param>
         </servlet>
         <servlet-mapping>
             <servlet-name>action</servlet-name>
             <url-pattern>*.do</url-pattern>
         </servlet-mapping>
          <taglib> 
       <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-html.tld</taglib-location> 
    </taglib>  
    <taglib> 
       <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-bean.tld</taglib-location> 
    </taglib>  
    <taglib> 
       <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-logic.tld</taglib-location> 
    </taglib>  
    <taglib> 
       <taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-nested.tld</taglib-location> 
    </taglib>  
    </web-app>
    struts.xml 示范:<?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd">
    <struts-config> <form-beans>
            ...............
        </form-beans>
    <action-mappings>
    ........................
           
    </action-mappings>
    <message-resources parameter="ApplicationResources"></message-resources>
    </struts-config>这是我最初学习时配置的,你自己简单修改就可以了!!!!初学先复制粘贴,再慢慢琢磨!!!