idea 新建ssm java ee_IDEA搭建SSM项目实现增删改查

首先打开IDEA,File—>New—>Project创建项目

b7a305c9f43fdf1af46c34501024de2b.png

选择左侧导航栏里的Maven,勾上勾,选择webapp

e891fe46e847baaf023df198d1cf78cd.png

按如下图进行填写

c348e216fa00b8b7bc458840ec73e659.png

3a87bc0b8a1a820b8c4628067adec38e.png

daa8768086f5da1143b759a247edf728.png

创建完成后进入项目,右下角弹出的提示点击右边的Enable Auto-Import,自动配置

f5ab2edc02543904b9c74d7c344241fb.png

连接数据库,我用的是Mysql数据库,准备好有数据的数据库表

80ffe34fc4bb17697c4dc099512415a2.png

1ce2949feeffe095c5d74db158f7a91d.png

在pom.xml里导入所需jar包:

e7bc3a219ded24c510f737c58c9a5d52.png

4.0.0

war

Student-ssm

com.accp

Student-ssm

1.0-SNAPSHOT

org.aspectj

aspectjweaver

1.8.8

org.springframework

spring-webmvc

4.3.12.RELEASE

org.springframework

spring-tx

4.3.12.RELEASE

org.springframework

spring-jdbc

4.3.12.RELEASE

org.mybatis

mybatis

3.4.5

org.mybatis

mybatis-spring

1.3.1

mysql

mysql-connector-java

5.1.44

com.alibaba

druid

1.1.2

javax.servlet

jstl

1.2

javax.servlet

javax.servlet-api

3.0.1

provided

总体结构:

b56c5a68e17adb655893acc078eccc90.png

web.xml代码:

characterEncodingFilter

org.springframework.web.filter.CharacterEncodingFilter

encoding

UTF-8

forceEncoding

true

characterEncodingFilter

/*

springmvc

org.springframework.web.servlet.DispatcherServlet

contextConfigLocation

classpath:springmvc.xml

springmvc

/

springmvc.xml代码:

entity学生实体类代码:

package com.accp.entity;

public class Studentinfo {

private long sid;

private String sname;

private String sgender;

private long sage;

private String saddress;

private String semail;

public long getSid() {

return sid;

}

public void setSid(long sid) {

this.sid = sid;

}

public String getSname() {

return sname;

}

public void setSname(String sname) {

this.sname = sname;

}

public String getSgender() {

return sgender;

}

public void setSgender(String sgender) {

this.sgender = sgender;

}

public long getSage() {

return sage;

}

public void setSage(long sage) {

this.sage = sage;

}

public String getSaddress() {

return saddress;

}

public void setSaddress(String saddress) {

this.saddress = saddress;

}

public String getSemail() {

return semail;

}

public void setSemail(String semail) {

this.semail = semail;

}

}

dao层StudentinfoDao代码:

package com.accp.dao;

import com.accp.entity.Studentinfo;

import java.util.List;

public interface StudentinfoDao {

ListqueryStudent();

int addStudentinfo(Studentinfo studentinfo);

int deleteStudentinfo(Studentinfo studentinfo);

int updateStudentinfo(Studentinfo studentinfo);

Studentinfo getByStudentId(Studentinfo studentinfo);

}

resources下xml里Studentinfo.xml代码:

select * from studentinfo;

select * from studentinfo where sid = #{sid}

insert into studentinfo value (default ,#{sname},#{sgender},#{sage},#{saddress},#{semail})

delete from studentinfo where sid = #{sid}

update studentinfo

sname = #{sname},

sgender = #{sgender},

sage = #{sage},

saddress = #{saddress},

semail = #{semail},

service层StudentinfoService代码:

package com.accp.service;

import com.accp.entity.Studentinfo;

import java.util.List;

public interface StudentinfoService {

ListqueryStudent();

int addStudentinfo(Studentinfo studentinfo);

int deleteStudentinfo(Studentinfo studentinfo);

int updateStudentinfo(Studentinfo studentinfo);

Studentinfo getByStudentId(Studentinfo studentinfo);

}

service层Impl实现类StudentinfoServiceImpl代码:

package com.accp.service.impl;

import com.accp.dao.StudentinfoDao;

import com.accp.entity.Studentinfo;

import com.accp.service.StudentinfoService;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import java.util.List;

@Service

public class StudentinfoServiceImpl implements StudentinfoService {

@Resource

private StudentinfoDao studentinfoDao;

public ListqueryStudent() {

return studentinfoDao.queryStudent();

}

public int addStudentinfo(Studentinfo studentinfo) {

return studentinfoDao.addStudentinfo(studentinfo);

}

public int deleteStudentinfo(Studentinfo studentinfo) {

return studentinfoDao.deleteStudentinfo(studentinfo);

}

public int updateStudentinfo(Studentinfo studentinfo) {

return studentinfoDao.updateStudentinfo(studentinfo);

}

public Studentinfo getByStudentId(Studentinfo studentinfo) {

return studentinfoDao.getByStudentId(studentinfo);

}

}

controller控制层StudentinfoController代码:

package com.accp.controller;

import com.accp.entity.Studentinfo;

import com.accp.service.StudentinfoService;

import org.springframework.stereotype.Controller;

import org.springframework.ui.Model;

import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

@Controller

public class StudentinfoController {

@Resource

private StudentinfoService studentinfoService;

@RequestMapping("/showList")

public String showList(Model model){

model.addAttribute("students",studentinfoService.queryStudent());

return "index";

}

@RequestMapping("/JumpAdd")

public String jumpAdd(){

return "add";

}

@RequestMapping("/AddList")

public String addList(Studentinfo studentinfo){

studentinfoService.addStudentinfo(studentinfo);

return "redirect:showList";

}

@RequestMapping("/DeleteS")

public String deleteS(Studentinfo studentinfo){

studentinfoService.deleteStudentinfo(studentinfo);

return "redirect:showList";

}

@RequestMapping("/JumpUpdate")

public String jumpUpdate(Studentinfo studentinfo,Model model){

model.addAttribute("stu",studentinfoService.getByStudentId(studentinfo));

return "update";

}

@RequestMapping("/UpdateS")

public String updateS(Studentinfo studentinfo){

studentinfoService.updateStudentinfo(studentinfo);

return "redirect:showList";

}

}

jsp页面代码:

显示页面(包含删除操作):

Title

增加

编号

姓名

性别

年龄

地址

email

操作

${stu.sid}

${stu.sname}

${stu.sgender}

${stu.sage}

${stu.saddress}

${stu.semail}

添加页面:

添加

姓名:

性别:

年龄:

地址:

邮箱:

修改页面:

修改

姓名:

性别:

年龄:

地址:

邮箱:

显示效果:

2e6b81277b0d94a9bf9beaae7e521496.png

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/529374.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

php mail centos_centos怎么发送邮件

一、安装sendmail与mail1、安装sendmail:1) centos下可以安装命令:yum -y install sendmail2) 安装完后启动sendmail命令:service sendmail start2、安装mail安装命令:yum install -y mailx二、发送邮件1、通过文件内容发送发送命…

php文件的作用,php入口文件的作用-PHP问题

php入口文件的作用php入口文件能够完成主动加载性能。解析PHP入口文件的主动加载性能php的主动加载:正在php5之前,咱们要用某个类或类的办法,那必需include或许require,之后能力应用,每一次用一个类,都需求…

emacs php 配置文件,如何配置emacs进行正确的PHP开发?

我使用web模式(http://web-mode.org/)混合HTML / PHP文件和php模式为纯PHP文件.最新版本的php-mode还推荐使用混合HTML / PHP文件的Web模式:https://github.com/ejmr/php-mode#avoid-html-template-compatibility.不同于其他模式,如mmm模式,mumamo或多网络模式,尝试…

php 5.3.9 漏洞,PHP-5.3.9远程执行任意代码漏洞(CVE-2012-0830) 详解

这个新的修复方法初衷是好的, 但是却带来一个严重的问题(5.3.10中已经修复), 这个问题最初是由Stefan Esser发现的. 请看之前(5.3.9)最终的修复方案(php_register_variable_ex):代码如下while (1) {if (zend_symtable_find(symtable1, escaped_index, index_len 1, (void **) …

java中随机数边界问题,java 简单Dice问题(随机数的运用)

[java]代码库/*** Dice Write a program that simulates rolling two dice using the following* steps: 1. Prompt the user for the number of sides for two dice. 2. “Roll” the* dice three times by generating a random number between 1 (inclusive) and the* number…

php 正则替换 ubb,php实现过滤UBB代码的类

本文实例讲述了php实现过滤UBB代码的类。分享给大家供大家参考。具体如下:PHP代码如下:class Day{function ubb($Text) { /// UBB代码转换//$Texthtmlspecialchars($Text);//$Textereg_replace("\r\n","",$Text);$Textereg_rep…

java单词测试,java单词 - 在线打字测试(dazi.kukuw.com)

java单词贡献者:15533470608类别:英文 时间:2018-08-04 22:32:16 收藏数:20 评分:0返回上页举报此文章请选择举报理由:广告/谣言/欺诈政治敏感色情/违法信息垃圾文章其他收藏到我的文章改错字public static…

java vector list,Java基础之:List——ArrayList Vector

Java基础之:List——ArrayList & VectorArrayList简单介绍ArrayList实现了List接口,底层是一个数组,并实现了可变的功能。底层属性(transient Object[] elementData;)在序列化时,忽略该属性。ArrayList实现了List接口&#xf…

java建立线性表的链式结构,数据结构学习----线性表的链式表示(Java实现)

线性表接口LList:package com.clarck.datastructure.linked;/*** 线性表接口LList,描述线性表抽象数据类型,泛型参数T表示数据元素的数据类型** author clarck**/public interface LList {/*** 判断线性表是否空* return*/boolean isEmpty();…

php prepare 批量,PreparedStatement批处理

PreparedStatement批量更新关键代码 无 import java.sql.Connection;import java.sql.PreparedStatement; //...String sql "insert into employee (name, city, phone) values (?, ?, ?)";Connection connection new getConnection();PreparedStatement pPrepa…

钉钉 php 推送,微信模板推送,钉钉信息推送

上午的时候看到有朋友需要微信推送,正好我也需要,之前一直用 Server 酱的,但是最近用不了,想找一个替代品,一开始准备选择钉钉,除了打卡,我很少使用钉钉,邮件提醒是备用方案&#xf…

java repaint 重画图形,学习笔记:WINDOWS的图形重绘基础

OnPaint()与OnDraw()的区别:OnPaint是WM_PAINT的消息响应函数,在MFC的基类里OnPaint函数调用了OnDraw()函数。OnPaint函数另外还调用了OnPrepareDC()函数。如果在窗口子类覆盖了OnPaint函数,当MFC调用我们重写的OnPaint函数时,就调…

php定义数据表类,phpwind中的数据库操作类

phpwind中的数据库操作类2021-01-22 20:12:15141/*来源:phpwind.net*/ClassDB{var$query_num0;functionDB($dbhost,$dbuser,$dbpw,$dbname,$pconnect0){$this->connect($dbhost,$dbuser,$dbpw,$dbname,$pconnect);}functionconnect($dbhost,$dbuser,$dbpw,$dbnam…

涡轮机叶片matlab强度分析论文,一种基于MATLAB及Pro_E的涡轮建模方法

自动化与控制与二一种基于MATLAB及Pro/E的涡轮建模方法王智明(中海油服油田技术事业部北京1011&am…

基于matlab的传热学虚拟实验开发,基于MATLAB的传热学课程虚拟实验软件的开发

215教育现代化2018 年 12 月第 49 期 教育信息技术 基于 MATLAB 的传热学课程虚拟实验软件的开发 周永利,李友荣,石万元,张力元,杨晨,卞煜,王国强,李俊,包键 ( 重庆大学 低品位能源利…

java做 binggo,Linux启动与停止spring boot工程的脚本示例

在springboot项目启动有三种方式:1、运行主方法程序2、使用命令mvn spring-boot:run 在命令行运行3、使用 mvn packpage打包位jar文件以后,使用java -jar yourapp.jar命令行运行一般我们在开发的时候经常使用的是前面两种运行方式,在部署实施…

php计划任务 框架,计划任务的使用 ThinkCMF内容管理框架,做最简约的ThinkPHP开源软件...

1、先不管是是否是独立分组,必须在Application\common\项目名下的Conf文件夹内创建2个文件一个是tags.php(项目默认有,直接加入需要执行的代码即可) 一个是 crons.php。注意这两个文件名为thinkphp标准文件名,不可以改变tages.php内容是&…

php按文章评论数排序,zblog获取分类文章排序按指定的时间排序、评论数量排序、浏览数量排序...

Zblog PHP在1.8版本的时候想要调用多个分类的文章,并且按照自己的需求去排序是很简单的事情,很多博友也利用这个方法进行最新文章排行、热门评论文章排行等等操作,现在随着ZblogPHP版本的升级,已经封装了数据库语句,导…

蚁群算法matlab vrp问题车辆限重,蚁群算法MATLAB解VRP问题

Excel exp12_3_2.xls内容:ANT_VRP函数:function [R_best,L_best,L_ave,Shortest_Route,Shortest_Length]ANT_VRP(D,Demand,Cap,iter_max,m,Alpha,Beta,Rho,Q)%% R_best 各代最佳路线%% L_best 各代最佳路线的长度%% L_ave 各代平均距离%% Shortest_Rout…

java线程6种状态转换,Java线程的生命周期和各种状态转换详解

在Java中,任何对象都有生命周期,线程也不例外,它也有自己的生命周期。当Thread对象创建完成时,线程的生命周期便开始了,当线程任务中代码正常执行完毕或者线程抛出一个未捕获的异常(Exception)或者错误(Error)时&#…