web.xml不是struts特有的啊,是web应用程序的部署文件啊
action和actionservlet不是一个东西
action是controller组件,struts提供了一个action父类,我们要继承这个父类并覆盖其execute()方法,它也控制页面转向滴吧,formbean主要是负责接受表单数据,也有表单验证和数据验证的
struts中的web.xml比其他的web.xml多了有关struts的配置信息。
struts-config.xml是struts框架的配置文件,它负责把struts的组件组装起来,以及如何使用它们啊。
工作原理上网上搜多的很
我也是初学,哈哈,自己买书看看啊。不过我做的项目不纯粹是用struts架构,中间又加了自己开发的一层。不过都大同小异了。
action和actionservlet不是一个东西
action是controller组件,struts提供了一个action父类,我们要继承这个父类并覆盖其execute()方法,它也控制页面转向滴吧,formbean主要是负责接受表单数据,也有表单验证和数据验证的
struts中的web.xml比其他的web.xml多了有关struts的配置信息。
struts-config.xml是struts框架的配置文件,它负责把struts的组件组装起来,以及如何使用它们啊。
工作原理上网上搜多的很
我也是初学,哈哈,自己买书看看啊。不过我做的项目不纯粹是用struts架构,中间又加了自己开发的一层。不过都大同小异了。
1. action :是处理业务的主要东东,是个.java的东东
2. actionForm: 是可以认为是一个对象,其中保存了你到传递的参数(也就是说所有要的传递的参数全放这里,参数的传递是由actionservlet来完成)
3.web.xml: 是所有web应用都有的东东 不论你用不用struts 还是什么什么什么 都不会缺这个
4.struts-config.xml :这是一个struts的配置文件 其中主要是告诉 actionservlet 哪个请求由哪个action来完成,即 mapping.不要一下看太多 慢慢看 否则会被漫天遍地的名词弄晕地
孙卫琴写的书《精通struts》
还可以
建议边做东西边学 还有本什么 实例(用struts做。)
2.ActionServlet是总控制器,一般不用我们编写东西,Action是一个一个的分控制器,是我们要写代 码进入的东西。在struts-config.xml配置,使Action和前台Web Form的请求对应起来。根据mvc的模式 ,Action里头一般写一些解析输入参数的工作。Action一般不应该写处理业务的代码,虽然它是.java
3. ActionForm是用来存Web Form的数据的,里面都是些get和set 还有reset和Validate方法
Struts-config.xml配置ActionForm,ActionMapping,这两个东西比较重要。还有个全局转发
4. 前台首先请求,
根据Web.Xml
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
显示index.jsp的页面
<!-- Standard Action Servlet Configuration (with debugging) -->
<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>
<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
设置了Struts-config.xml和*.do的问题。以后的请求,都通过了Action Servlet,而Action Serlet里面的转发动作则是来自Struts-config.xml里的设置。
<form-bean
name="MyActionForm"
type="Controller.MyActionForm"/> </form-beans>
<global-forwards>
<!-- Default forward to "Welcome" action -->
<!-- Demonstrates using index.jsp to forward -->
<forward
name="welcome"
path="/Welcome.do"/>
</global-forwards><actionmappings>
<action
path="/AdminLogin"
type="Controller.AdminloginAction"
name="MyActionForm">
<forward name="success" path="/Admin/AdminIndex.html"/>
<forward name="failure" path="/Admin/fail.jsp"/>
</action>
</actionmappings>
Action Form是设置好Form bean
Action Mapping里path是html表单里〈form aciton="**.do">的**,type是对应的Action的.java,name 是要用来存数据的action form,两个forward,是Action的返回值判断跳转。