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.pswp.cn/news/529374.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/529374.shtml
英文地址,請注明出處:http://en.pswp.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)時&#…