ssm全注解例子20200826094535[共2页].doc

上传人:scccc 文档编号:11139537 上传时间:2021-07-04 格式:DOC 页数:2 大小:21.50KB
返回 下载 相关 举报
ssm全注解例子20200826094535[共2页].doc_第1页
第1页 / 共2页
ssm全注解例子20200826094535[共2页].doc_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
资源描述

《ssm全注解例子20200826094535[共2页].doc》由会员分享,可在线阅读,更多相关《ssm全注解例子20200826094535[共2页].doc(2页珍藏版)》请在三一文库上搜索。

1、ssm 全注解例子 【篇一: ssm 全注解例子】public boolean isexitbynameandpass(user user) returnuserdao.isexitbynameandpass(user); 业务逻辑在这里包括了判断用户是否存在,保存用户信息,获取用户信息,删除用户,更新用户信息等 通过上面两个类业务逻辑层也就完成了,接下来写视图控制器,这里只是写了一个简单的登录控制器 loginaction.javapackage com.ssh.user.action;importjavax.annotation.resource;importorg.apache.stru

2、ts2.convention.annotation.action;importorg.apache.struts2.convention.annotation.result;importcom.opensymphony.xwork2.actionsupport;importcom.ssh.user.dao.userdao;import com.ssh.user.model.user; *类名称: loginaction * 类描述:用户控制器的实现 * 创建人: anan* 创建时间: 2012-12-21 下午 11:17:36 * 修改人: anan * 修改时间:2012-12-21 下

3、午 11:17:36 * 修改备注: * version */action(value = loginaction , results = result(name =loginsuccess , location = /loginsuss.jsp ), result(name =loginfailer , location = /loginfailer.jsp ) )public classloginaction extends actionsupport private static final longserialversionuid = -2266695172069461659l; re

4、source privateuserdao userdao; private user user; public user getuser() return user; public void setuser(user user) this.user = user;public string login() boolean flag =userdao.isexitbynameandpass(user); if(flag) return loginsuccess return loginfailer 这个就是控制层。再写几个 jsp 文件来测试一下内容如下:index.jsp% page lan

5、guage= java import= java.util.* pageencoding=utf-8 % %taglib prefix= s uri= /struts-tags % string path =request.getcontextpath();string basepath =request.getscheme()+ :/ +request.getservername()+ :+request.getserverport()+path+ / !doctype html public -/w3c/dtd html 4.01 transitional/en html head bas

6、ehref= %=basepath% title my jsp index.jsp starting page /titlemeta http-equiv= pragma content= no-cache meta http-equiv=cache-control content= no-cache meta http-equiv= expirescontent= 0 meta http-equiv= keywords content=keyword1,keyword2,keyword3 meta http-equiv= descriptioncontent= this is my page

7、 link rel= stylesheet type= text/csshref= styles.css /head body s:form action= loginaction!logins:textfield name= user.username label= username /s:textfields:textfield name= user.password label= password /s:textfields:submit value= login /s:submit /s:form /body /htmlloginfailer.jsp% page language= j

8、ava import= java.util.* pageencoding=utf-8 % string path = request.getcontextpath();string basepath= request.getscheme()+ :/ +request.getservername()+ :+request.getserverport()+path+ / !doctype html public -/w3c/dtd html 4.01 transitional/en html head basehref= %=basepath% title my jsp loginfailer.j

9、sp starting page/title meta http-equiv= pragma content= no-cache meta http-equiv= cache-control content= no-cache meta http-equiv=expires content= 0 meta http-equiv= keywords content=keyword1,keyword2,keyword3 meta http-equiv= descriptioncontent= this is my page link rel= stylesheet type= text/csshref= styles.css /head body 登录失败 /body /htmlloginsuss.jsp 接下来打开浏览器,输入可以看到下图页面就可以测试了觉得使用了 ssh 结构之后整个工程的层次感就那样出来了。搞鼓一下收获还是蛮大的,基于注解的 ssh 是比 xml 方便很多,看大家喜欢吧源码下地址【篇二: ssm 全注解例子】做完这些,我们就可以开始创建 maven 工程了。选择 new-other.- maven- maven project ,然后选择下一步

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1