note:
(1)注意几种action用法。
Object
|-Action
|- BaseAction
|- DispatchAction
|- EventDispatchAction
|- LookupDispatchAction
|- MappingDispatchAction
|- DownloadAction
|- ForwardAction
|- IncludeAction
|- LocaleAction
|- SwitchAction
|-DefinitionDispatcherAction
|-MockAction
|-ReloadDefinitionsAction
|-ScriptAction
|-TilesAction
|-ViewDefinitionsAction
(2)注意几种ActionForm的用法。
(3)Struts的核心是Action,而Action的核心就是一个配置文件——struts-
config.xml
struts-config.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-bean name="loginForm" type="com.test.forms.LoginForm"></form-bean> </form-beans> <global-exceptions /> <global-forwards /> <action-mappings> <!-- (1)别忘了指定对应的name,path里面的/路径以WebRoot为根目录. (2)这里的path,在jsp的action中,可以用basePath直接拼出,也可以不带/并且不写basePath。 --> <action path="/test/login" type="com.test.actions.LoginAction" name="loginForm"> <forward name="success" path="/jsp/success.jsp"></forward> <forward name="failed" path="/jsp/failed.jsp"></forward> </action> </action-mappings> <message-resources parameter="com.test.ApplicationResources" /> </struts-config>