Struts1:只适用于B/S架构开发
MVC模式简介(Model-模型层,View-视图层,Controller-控制层)
开发步骤:
1、下载并添加一个Struts的支持;(下载一个Struts1的jar包做好支持)
2、配置Web应用(web.xml),将ActionServlet做为中央控制器;(配置web应用中央控制器)
修改web.xml
3、编写JSP、ActionForm、Action并配置struts-config.xml;
将struts-config.xml添加到web-inf下面在struts-config.xml中只留from-beans,global-forwards,action-mappongs,message-resources
配置ActionFrom <from-bean name="userForm" type="包路径"/>,
然后配置Action<action path="/login" type="包路径" name="userForm" scope="request(返回)session(进入)"/>
然后再配置返回页面跳转<forward name="success" path="/success.jsp"> <forward name="error" path="/fail.jsp">
资源文件不用动
4、编写JavaBean(.java),用于业务处理与数据访问;
创建dao,entity,service,struts.action,struts.form,util包
在util包中。创建SQLHelp,Db,StatementTypeEnum工具文件
5、布置,运行:通过浏览器访问。