首先介绍下什么是strus,spring和mybatis
strus:
它通过采用JavaServlet/JSP技术,实现了基于Java EEWeb应用的MVC设计模式的应用框架。
(1)constant是配置常量
(2)package提供了将多个Action组织为一个模块的方式 :
name:package名称
namespace:定义package命名空间
(3)action中的name表示前台提交的地址,class表示这个action的类路径,method表示请求要调用什么方法去进行处理,可有可无,没有的话,action要写execute这个方法,有的话,自己给方法的名字。
result中 name与action中返回的字符串相对应,后面则是对应的jsp页面。
spring:
spring是一个bean工厂
bean标签中的id代表着这个bean标签的标识,class表示的bean类,即bean的路径
property,就是找当前配置文件里的bean ,如<property name="a" ref="b"/>就是找到id为b的bean
mybatis:
用于写sql语句,如图
test中包含的是一个boolean值
接下来展示一部分代码
刚开始的注册界面
在点击注册后会进入web.xml,并执行filter,这时strtus就开始了,form表单通过action=Resgister.action跳到
<action name="Register" class="RegisterAction">,然后进入RegisterAction(Java页面)
其实这里可以只留下set方法,到这里会执行execute()方法,最后返回的success会反馈到struts的
<result name="success">xitongguanli/regsuccess.jsp</result>,然后跳到regsuccess.jsp,表示注册成功,
而数据库的更新是userService.saveUser(user)完成的。我们需要操作的就是在mybatis中写好sql语句,其他则
不用管,以下是其他在操作数据库时我们不会“使用”到的类