手机版

春季靴mybatis Vue.js ElementUI实现数据的增删改查实例代码(二)

时间:2021-09-04 来源:互联网 编辑:宝哥软件园 浏览:

在上篇文章给大家介绍了春天的靴子我的巴蒂斯Vue。js ElEMENTui实现数据的增删改查实例代码(一),接下来我们添加分页相关的依赖,时间紧张,直接上代码了,贴上我的砰的一声文件

项目xmlns=' http://aven。阿帕奇。org/POM/4。0 .0 ' xmlns : xsi=' http://www。w3。org/2001/XMLSchema-instance ' xsi 3360 schema location=' http://aven。阿帕奇。org/POM/4。0 .0 http://maven.apache.org/xsd/maven-4.0.0.xsd'车型版本4。0 .0/型号版本groupIdcom.imooc/groupId artifactIddemo/artifactId版本0。0 .1-快照/版本包-从存储库查找父项-/父项属性项目。建造。sourceencodingutf-8/项目。建造。sourceencoding项目。报道。output en coding TF-8/项目。报道。输出Java编码。1.8版本/Java。版本/属性依赖关系groupIdorg.mybatis.spring.boot/groupId artifactIdmybatis-spring-boot-starter/artifactId版本1。1/版本/依赖关系groupIdorg.springframework.boot/groupId artifactId spring-boot-starter-web/artifactId/依赖关系group id MySQL/group id artifactmysql-connector-Java-http://localhost :8080/健康相关性groupIdorg.springframework.boot/groupId artifactId spring-boot-starter-actuator/artifactId/相关性相关性groupIdcom.github.pagehelper/groupId artifactidpage帮助者/artifactId版本4 .1 .6/版本/相关性/相关性构建插件groupIdorg.springframework.boot/groupId人工智能启动插件/人工智能/插件/插件/构建/项目接下来是yml文件,主要加入了mybatis的配置,以及结构化查询语言的打印

弹簧:数据源:名称:测试网址: JDBC :我的SQL ://localhost/imooc?useUnicode=true字符编码=utf-8 usessl=false username : root password : 123456 driver-class-name : com。MySQL。JDBC。驱动程序mybatis :类型-别名-包: com。imoc。模型映射器-位置3360类路径: mybatis/mapper/* .XML check-config-location : true config-location :类路径: my batis/my batis-config。xmllogging : level : com。伊莫克。reportor : debug com。伊莫克。服务。impl :调试com。伊莫克。控制器:调试com。伊莫克。activem q 3360调试接下来是仓库文件

@ Repositorypublic界面用户存储库{ listsuserfindustrers by username(@ Param(' username ')字符串用户名);int GetCount();内部保存用户(用户用户);用户用户;int remove user(@ Param(' userId ')int userId);}服务文件

@Servicepublic类UserServiceImpl实现了用户服务{ @ Autowired私有用户存储库用户存储库;@Override public MapString,Object getTableData(int pageNum,int pageSize,String username){ try { page helper。起始页(页码、页面大小);列表用户用户列表=用户存储库。findbusersbyusername(用户名);int count=用户存储库。getcount();MapString,Object tableData=new HashMap();tableData.put('list ',用户列表);tableData.put('count ',count);返回tableData} catch(异常e){ e . print stack trace();}返回null} }公共接口UserService { MapString,Object getTableData(int pageNum,int pageSize,String username);}控制器文件

@RestControllerpublic类用户控制器{ @Autowired私有用户服务用户服务;@GetMapping('getTableData ')公共MapString,Object getTableData(int pageNum,int pageSize,String username){ try { return user service。getTableData(页码、页面大小、用户名);} catch(异常e){ e . print stack trace();}返回null}}实体类

公共类用户{私有整数用户标识;私有字符串用户名;私人字节性;私人日期创建时间;公共整数getUserId(){ 0返回userId} public void setUserId(整数userId){ this。userId=userId}公共字符串getUsername(){ 0返回用户名;} public void setUsername(String username){ this。用户名=用户名;} public Byte getSex(){ return sex;} public void setSex(Byte sex){ this。性=性;} public Date getCreateTime(){ return createTime;} public void setCreateTime(Date createTime){ this。createTime=createTime}}sql

CREATE TABLE ` t _ user `(` user _ id ` int(11)NOT NULL AUTO _ INCREMENT,` username ' varchar(32)DEFAULT NULL,` sex ' tinyint(4)DEFAULT NULL,` CREATE _ time ' datetime DEFAULT NULL,PRIMARY KEY(` user _ id `))ENGINE=InnoDB AUTO _ INCREMENT=10003 DEFAULT CHARSET=utf8在静电目录下新建index.html文件

!DOCTYPE html html lang=' ZH ' head meta charset=' UTF-8 ' title spring boot mybatis vue element ui/title link rel='样式表href='//cdn。bootscs。com/element-ui/1。1 .2/主题-默认/索引。CSS ' rel=' external nofollow '脚本src=' http://cdn。bootscs。com/vue/2。1 .8/vue。量滴js '/script script src='

@ EnableAutoConfiguration @ Configuration @ ComponentScan @ MapperScan(' com。伊莫克。存储库')@回弹应用公共类演示应用程序{ public static void main(String[]args){ spring application。运行(演示应用程序。类,args);}}启动项目,打开http://localhost :8080/index。超文本标记语言

推荐专题阅读:

板簧罩开发教程://www.jb51.net/Special/943.htm

mybatis教程://www.jb51.net/Special/774.htm

以上所述是小编给大家介绍的春天的靴子我的巴蒂斯Vue。js ElEMENTui实现数据的增删改查实例代码(二),希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对我们网站的支持!

版权声明:春季靴mybatis Vue.js ElementUI实现数据的增删改查实例代码(二)是由宝哥软件园云端程序自动收集整理而来。如果本文侵犯了你的权益,请联系本站底部QQ或者邮箱删除。