使用sturts(也就是struts1)进行web项目开发,首先需要搭建struts框架
建立web项目
2.引入.jar包到lib文件夹下(点击下载struts-1.3.10-all)
建立struts-config.xml文件(WEB-INF目录下创建)
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"> <struts-config> <action-mappings> <action path="/hello" type="com.test.action.HelloAction"> <forward name="he" path="/hello.jsp"></forward> </action> </action-mappings> </struts-config>
第二行代码我们可以直接从工具包源码中获取
4. 把struts配置到web.xml中
<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> <load-on-startup>0</load-on-startup> </servlet> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping>