ssm框架搭建+easyui增刪改查實現
原始碼下載頁面(一個完整的專案):http://download.csdn.net/detail/jinwufeiyang/9648208
資料庫檔案下載:http://download.csdn.net/detail/jinwufeiyang/9700588
spring版本:4.0.6
mybatis版本:3.2.5
1、專案目錄結構
其中,controller包下存放控制層檔案,dao下存放各個model類相關的資料庫操作介面,entity下放置各種model類,mappers下放置各個dao對應的對映檔案,service服務層就不說了,放置各種service介面,impl是其具體實現類。
2、web.xml檔案配置
<?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <display-name></display-name> <welcome-file-list> <welcome-file>login.jsp</welcome-file> </welcome-file-list> <!-- Spring配置檔案 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <!-- 編碼過濾器 --> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <async-supported>true</async-supported> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- 配置Spring監聽器 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 新增對SpringMVC的支援 --> <servlet> <servlet-name>SpringMVC</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-mvc.xml</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>SpringMVC</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> </web-app>
3、log4j.properties配置日誌
log4j.rootLogger=DEBUG, Console
#Console
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n
log4j.logger.java.sql.ResultSet=INFO
log4j.logger.org.apache=INFO
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG
4、mybatis-config.xml配置
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <!-- 別名 --> <typeAliases> <package name="com.java.entity" /> <!-- 後面書寫類全名時預設加該包名字首如:<resultMap type="User"... --> </typeAliases> </configuration>
5、spring-mvc.xml配置
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd"> <!-- 使用註解的包,包括子集 --> <context:component-scan base-package="com.java.controller"></context:component-scan> <!-- 檢視解析器 --> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/"></property> <property name="suffix" value=".jsp"></property> </bean> </beans>
6、applicationContext.xml配置
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd"> <!-- 自動掃描該包下面的bean檔案 --> <context:component-scan base-package="com.java.service"></context:component-scan> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <!-- <property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/> --> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://localhost:3306/crm"/> <property name="username" value="root"/> <property name="password" value="root"/> </bean> <!-- 配置MyBatis的sqlSessionFactory --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource"></property> <property name="configLocation" value="classpath:mybatis-config.xml"></property> <property name="mapperLocations" value="classpath:com/java/mappers/*.xml"></property> </bean> <!-- Mapper介面所在包名,Spring會自動查詢其下的Mapper --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.java.dao"></property> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property> </bean> <!-- 配置transactionManager事務管理器 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"></property> </bean> <!-- 配置事物通知屬性 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <!-- 定義事物傳播特性 --> <tx:attributes> <tx:method name="insert" propagation="REQUIRED"/> <tx:method name="update*" propagation="REQUIRED" /> <tx:method name="edit*" propagation="REQUIRED" /> <tx:method name="save*" propagation="REQUIRED" /> <tx:method name="add*" propagation="REQUIRED" /> <tx:method name="new*" propagation="REQUIRED" /> <tx:method name="set*" propagation="REQUIRED" /> <tx:method name="remove*" propagation="REQUIRED" /> <tx:method name="delete*" propagation="REQUIRED" /> <tx:method name="change*" propagation="REQUIRED" /> <tx:method name="check*" propagation="REQUIRED" /> <tx:method name="get*" propagation="REQUIRED" read-only="true" /> <tx:method name="find*" propagation="REQUIRED" read-only相關推薦
ssm框架搭建+easyui增刪改查實現
原始碼下載頁面(一個完整的專案):http://download.csdn.net/detail/jinwufeiyang/9648208 資料庫檔案下載:http://download.csdn.net/detail/jinwufeiyang/9700588
ssm 框架使用者的增刪改查(前天jsp寫的)
首先就是建立使用者表了 package com.xblh.pojo; 第二步,dao層 第三步:資料庫查詢 因為為了分頁方便最好建立一個工具類 service層 控制層 最後一步就是前臺頁面了,前臺我是用easyui 做的 <
MyBatis框架搭建及增刪改查操作
一.搭建好myBatis的環境 1.引入jar包 (1).mybatis-3.2.7jar核心jar (2).mysql核心jar (3).junit-4.9.jar 2.建立mybatis全域性配置檔案SqlMapConfig.xm(名字自
SSM框架搭建(Spring+SpringMVC+MyBatis)與easyui整合並實現增刪改查實現
一、用myEclipse初始化Web專案 新建一個web project: 二、建立包 controller //控制類 service//服務介面 service.impl//服務實現類 dao //data access object
03 基於umi搭建React快速開發框架(封裝列表增刪改查)
前言 大家在做業務系統的時候,很多地方都是列表增刪改查,做這些功能佔據了大家很長時間,如果我們有類似的業務,半個小時就能做出一套那是不是很爽呢。 這樣我們就可以有更多的時間學習一些新的東西。我們這套框架對此做了下封裝,適合的小夥伴也可以借鑑封裝到自己的框架當中去。核心思想用的React 高階元件
SSM 整合開發+通用的增刪改查實現
前一段時間開發java web專案都是採用的SSH框架,開發中發現在使用Hibernate做持久層開發的時候用法不夠靈活,過於笨重,因此,改用MyBaties,結合Spring、SpringMvc框架,現將配置過程梳理如下: 一、專案結構
Easyui DataGrid增刪改查實現
Java使用Spring MVC以及Mybatis實現 DataGrid的增刪改查/分頁,以Mysql資料庫為例,效果: 具體程式碼如下: 0、資料庫指令碼: CREATE TABLE `compy` ( `id` bigint(11) NOT NULL A
Django框架day72------orm增刪改查、django請求的生命週期
一、orm介紹 1.orm的使用 (1)tools--->Run manage.py Task makemigrations(記錄資料庫的修改記錄) migrate(把資料同步到資料庫) (2)python3 manage.py makemigrat
MyBatis學習——第一篇(增刪改查實現)
1:MyBatis入門 1.1 Mybatis概述 MyBatis 是一款優秀的持久層(ORM)框架,它支援定製化 SQL、儲存過程以及高階對映。MyBatis 避免了幾乎所有的 JDBC 程式碼
jQuery EasyUi 增刪改查
easyui的crud(dialog,datagrid、form講解) 1、?開啟tab頁 2、?建立dao 3、?Web的增刪改查與配置 4、?使用datagrid承載查詢資料 5、?增加和修改使用dialog與form 6、?使用ajax做刪除 7、?解決ta
JDBC的簡單增刪改查實現
這裡我們先在資料庫建立一個userinfo表: CREATE TABLE userinfo ( userid` INT (11), userName VARCHAR (180), &n
第四十章:Spring MVC框架之傳統增刪改查06
傳統CRUD 列表頁面: 新增頁面: 編輯頁面: 刪除操作: 匯入SpringMVC jar包 commons-logging-1.1.3.jar spring-aop-4.0.0.RELEASE.jar spring-beans-4.0.0.RELEAS
Python的Django框架-資料庫查詢(增刪改查)
建立專案 django-admin startproject django_model 建立應用 python manage.py startapp model 配置應用 model, 編輯 django_model/settings.py
spring boot與mybatis如何搭建一個增刪改查的程式
例項程式是基於springboot,Mybatis搭建的,簡單的demo,能實現增刪改查等功能。 Spring Boot是由Pivotal團隊提供的全新框架,其設計目的是用來簡化新Spring應用的初始搭建以及開發過程。該框架使用了特定的方式來進行配置,從而使開發人員不再需要定義樣板化的配置
EF框架DAL的增刪改查加批刪
這個是DAL 如果寫到db.Notice.Add的時候報錯的話需要在Model層的引用裡賦值一個東西的路徑 賦值後進入到DAL層選擇引用 新增引用後就可以了 &n
JavaWeb框架-SpringMVC-2-增刪改查
話說 各位讀者,中午好!前面一篇部落格介紹了SpringMVC環境搭建及引數傳遞,熟悉這個後,實現增刪改查(CURD)就很簡單了。今天目標就是實現一個非常簡單的CURD. 目標 1、根據get或者post請求,來選擇呼叫方法 2、使用自帶過濾器處理中
Myeclipse+tomcat+mysql,B/S實現學生資訊的增刪改查(實現篇)
小生第一次用Myeclipse和Mysql做東西,邊學邊做,處處遇到問題,然後自己搜資料和分析去解決 測試通過! 工程檔案目錄 index.jsp <%@ page language="java" import="java.util.*" pageEncod
【greenDAO3】 專案搭建與增刪改查操作
最近需要開始一個新的專案了,考慮到既然是新專案了,那麼一些常用的框架肯定也要用當下最火的!這次的新專案中涉及到了本地資料儲存,很早前有個專案的本地資料庫框架用的是ActiveAndroid,github找了下這個框架,發現已經兩年多已經沒有更新了。然後就想到了一直沒
SSM簡易專案(增刪改查)
本專案是一個Spring+SpringMVC+Mybatis+MySQL的一個小專案,專案只有簡單的增刪改查。 前端用了JQuery和Boostrap(其實也沒用啥)。 純粹是為了練習一下框架整合。 版本:Spring(4.3.6)、SpringMVC(4.3.6)、M