首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

《struts-入门简洁分析struts的工作原理》-只是简单的分析配置文件,对内部的FormBean等有关的知识未涉及

2012-10-17 
《struts----入门简要分析struts的工作原理》---只是简单的分析配置文件,对内部的FormBean等有关的知识未涉

《struts----入门简要分析struts的工作原理》---只是简单的分析配置文件,对内部的FormBean等有关的知识未涉及

简要分析struts的工作原理:

1.      由浏览器向服务器发送请求。/*.do

2.      服务器接受请求,并按照web.xml的配置调用相应的Servlet进行处理

<!--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">  <display-name></display-name>    <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>convertNull</param-name>      <param-value>true</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>    <welcome-file-list>    <welcome-file>index.jsp</welcome-file>  </welcome-file-list>  </web-app>


3.      服务器会将请求*.do的处理交给org.apache.struts.action.ActionServlet这个Servlet处理,这个Servlet又会将请求按照/WEB-INF/struts-config.xml配置的信息,找到对应的action进行处理。

4.我们将会在struts-config.xml中配置,action的对外访问路径

<!--struts-config.xml--><?xml version="1.0" encoding="UTF-8"?><!DOCTYPE struts-config PUBLIC          "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"          "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd"><struts-config><action-mappings><action path="/Test" type="com.fenghuo.struts.test.Test"><forward name="success" path="/WEB-INF/jsp/test.jsp"></forward></action></action-mappings></struts-config>
相关的内容可以参看提供的xml文件

热点排行