Struts

Struts web.xml and conig.xml
Previous Home Next
  1. Now Your web.xml file which hold your Action Class or ActionServlet , config struts-cofig.xml, and all the TagLibary import into your application.
  2. <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.0"
    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_3_0.xsd">
    <!-- Action Class/ActionServlet Map here -->
     <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet
    </servlet-class>
    <init-param>
     <param-name>config</param-name>
     <param-value>/WEB-INF/struts-config.xml
    	</param-value>
    </init-param>
    <init-param>
     <param-name>debug</param-name>
     <param-value>2</param-value>
    </init-param>
    <init-param>
     <param-name>detail</param-name>
     <param-value>2</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
     </servlet>
     <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
     </servlet-mapping>
     <session-config>
    <session-timeout>
     30
    </session-timeout>
     </session-config>
    	<!-- First JSP page( index) map here -->
     <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
     </welcome-file-list>
     <jsp-config>
    	<!-- All TagLibrary map here -->
    <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-html.tld</taglib-uri>
     <taglib-location>/WEB-INF/struts-html.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>
    <taglib>
     <taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
     <taglib-location>/WEB-INF/struts-tiles.tld
     </taglib-location>
    </taglib>
     </jsp-config>
    </web-app>
    
  3. Your struts-config.xml file here:
  4. <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE struts-config PUBLIC
    "-//Apache Software Foundation
    //DTD Struts Configuration 1.3//EN"
    "http://jakarta.apache.org/struts
    /dtds/struts-config_1_3.dtd">
    <struts-config>
    <form-beans>
    <!-- Model of your application or Beans map here -->
    </form-beans>
    <global-exceptions>
    </global-exceptions>
    <!-- Forward page map here-->
    <global-forwards>
    <forward name="welcome"  path="/Welcome.do"/>
    </global-forwards>
    <!-- Action class, success page, failure page,
    and all the action related stuff map here -->
    <action-mappings>
    <action path="/Welcome" forward="/welcomeStruts.jsp"/>
    </action-mappings> 
    <controller processorClass="org.apache.struts
    .tiles.TilesRequestProcessor"/>
     <!--ApplicationResource file map here -->
    <message-resources parameter="com/myapp/struts
    /ApplicationResource"/>
    <!-- ============= Tiles plugin ============-->
    <plug-in className="org.apache.struts.tiles.TilesPlugin" >
    <set-property property="definitions-config"
    value="/WEB-INF/tiles-defs.xml" />  
    <set-property property="moduleAware" value="true" />
    </plug-in>
    <!-- ========== Validator plugin ============= -->
    <plug-in className="org.apache.struts.validator
    .ValidatorPlugIn">
    <set-property
      property="pathnames"
      value="/WEB-INF/validator-rules.xml,/WEB-INF
      /validation.xml"/>
    </plug-in>
      </struts-config>
    

     

  5. Output of your program, with some changes into title, headline and message
Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: