2013年10月17日星期四

springmvc + myibatis + spring integration example ( for reference only )

Nothing else, in order to learn easyui + ztree, then wrote a demo,
service uses springmvc + myibatis + spring implementation,
Screenshots
login :

home page :

List page :

tree page :

add pages :

server code section screenshot:
spring configuration:
<?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:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

    <context:annotation-config/>
    <tx:annotation-driven transaction-manager="transactionManager" />
    <context:component-scan base-package="com.school.portal" />

    
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />             
    </bean>

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/school?useUnicode=true&amp;characterEncoding=utf8" />
<property name="username" value="root" />
<property name="password" value="123456" />
<property name="maxActive" value="80" />
<property name="maxIdle" value="20" />
<property name="maxWait" value="3000" />
</bean>

    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />           
        <property name="typeAliasesPackage" value="com.school.portal.entity" />    
        <property name="mapperLocations" value="classpath*:mapper/*.xml" />
        <property name="configLocation" value="classpath:myibatis-config.xml"></property>
    </bean>

    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.school.portal.dao" />
        <property name="markerInterface" value="com.school.portal.dao.BasicMapper"/>    
    </bean>
    
    <bean id="springContext" class="com.school.portal.SpringContext"/>
    
    <import resource="spring/spring-mvc.xml"/>
</beans>


springmvc configuration:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
        http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
        http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context.xsd">

<!-- DispatcherServlet Context: defines this servlet's request-processing 
infrastructure -->
<context:component-scan base-package="com.school.portal.web.controller" />

<interceptors>
<interceptor>
<mapping path="/**" />
<beans:bean class="com.school.portal.web.interceptor.UserDetailInterceptor" />
</interceptor>
</interceptors>



<!-- 完成请求和注解POJO的映射 -->
<beans:bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
</beans:bean>
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/views/"></beans:property>
<beans:property name="suffix" value=".jsp"></beans:property>
</beans:bean>


<beans:bean class="org.springframework.web.servlet.view.BeanNameViewResolver">
<beans:property name="order" value="1" />
</beans:bean>

<beans:bean id="jsonView" class="com.school.portal.web.view.CilentJsonView" />
</beans:beans>


dao code :
package com.school.portal.dao;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

public interface BasicMapper<T,PK extends Serializable> {

public abstract PK save(T t);

public abstract T getByPrimaryKey(PK id);

public abstract int updateByPrimaryKey(T t);

public abstract void deleteByPrimaryKey(PK id);

public abstract void deleteAllByPrimaryKey(List<PK> ids);

public abstract List<T> findAll();

public abstract int getTotal(@Param(value="paramMap")Map<String,Object> paramMap);

public abstract List<T> findByPage(@Param(value="pageNo")int pageNo,@Param(value="pageSize")int pageSize,
                           @Param(value="sort")String sort,@Param(value="order")String order,
                           @Param(value="paramMap")Map<String,Object> paramMap);


}

There are some features not implemented , just some small examples, are interested can focus github, I will spread at source
------ Solution ---------- ----------------------------------

landlord to do good !

------ Solution ------------------------------------ --------
small Niubi ah
------ Solution ----------------------- Demo ---------------------
learn ~
------ Solution - -------------------------------------------
say good source it ? ?
------ For reference only -------------------------------------- -
pro , leaving the mail , send your mail can also be ...
------ For reference only -------------------- -------------------

yuanma
------ For reference only -------------------------------- -------
real Programmers
------ For reference only ------------------------ ---------------
good fast hardware . . Can you give a source brother ! !
------ For reference only -------------------------------------- -

Please landlord must believe me, you are a good man.

378325537@qq.com
------ For reference only ----------------------------- ----------

Please landlord must believe me, you are a good man.   
  
378325537@qq.com  

pro , has been sent to your mailbox !
------ For reference only ------------------------- --------------

learned a very powerful send a 807015628@qq.com
------ For reference only ---------------------------------------


Sent !
------ For reference only ------------------------------- --------
is_zhoufeng@163.com
------ For reference only ---------------------- -----------------


has been sent !
------ For reference only -------------------------------------- -

---- - For reference only ---------------------------------------
send a brother see, brother to help check, review the code under
------ For reference only ---------------------------- -----------
ensignli@sina.com
------ For reference only ------------------- --------------------
Men also source : coding234@sina.com, good landlord
------ For reference only - --------------------------------------
I have source code , xiaoniba2750 @ sohu. com, thank you brothers and friends
------ For reference only --------------------------------- ------
request to share source code , thank 715647008@qq.com
------ For reference only ------------------- --------------------
with demand , thank you share 526721484@qq.com
------ For reference only ---------------------------------------
1653456033@qq.com
------ For reference only ---------------------------------------
429614073@qq.com ; please demo
------ For reference only --------------------------------- ------
1227730812@qq.com
------ For reference only ------------------------ ---------------
wanghaichao_9@163.com give me a source to a bar, learning to learn.
------ For reference only -------------------------------------- -
ybxywz@126.com

good landlord ! ! !
------ For reference only -------------------------------------- -
LZ doing really good , find source
whaonchong@163.com

------ For reference only ---------------------------------- -----
landlord brother , can send the source code to me ah , want to learn thank you
cnlag@qq.com
beyoyo@163.com
------ For reference only ----------------------------- ----------
can send the source code to me ah , want to learn thank ynljwcy@gmail.com
------ For reference only - -------------------------------------
chenghui_0317@163.com
------ For reference only ---------------------------------------
 good landlord 1121655859 @ qq .. com
------ For reference only ---------------------------------------
at the mailbox , LZ can do not give a reference source , are learning framework
------ For reference only ----------------------------- ----------
seeking landlord send a code to the mailbox , thank you
13981978030@163.com
------ For reference only ----------------------------- ----------
814983490@qq.com, with demand
------ For reference only ----------------- ----------------------
4221275@qq.com
just watching spring video it ~ ~
------ For reference only ------------------------- --------------
landlord to send a chant , pqchuang@163.com
------ For reference only --------- ------------------------------
seeking a source ! ! 826654664@qq.com
------ For reference only --------------------------------- ------
top landlord , seeking a source code , 1254777957@qq.com
------ For reference only -------------- -------------------------
want to learn , seeking source : 1946176242@qq.com
------ For reference only ---------------------------------------

issued < br> ------ For reference only ---------------------------------------

issued
------ For reference only ----------------------------- ----------

issued
------ For reference only ------------------- --------------------

issued  
Thank you very much ! ! !
------ For reference only -------------------------------------- -
can send you a source , the landlord good life of peace !
------ For reference only -------------------------------------- -
landlord , a copy source code to see if your tree , dynamic additions and deletions . fjy931101@163.com
------ For reference only ------------------------------- --------

issued
------ For reference only --------------------- ------------------
source you can send a landlord good life of peace ! 516121616@qq.com
------ For reference only ------------------------------- --------

issued
------ For reference only --------------------- ------------------
landlord seeking a source to learn 1771515519@qq.com
------ For reference only ---------------------------------------

issued < br> ------ For reference only ---------------------------------------
123671949@qq.com good landlord
------ For reference only ---------------------------------------

issued < br> ------ For reference only ---------------------------------------
532742223@qq.com, good landlord
------ For reference only --------------------------- ------------

issued
------ For reference only ----------------- ----------------------
787601802@qq.com good landlord
------ For reference only ---------------------------------------
492438706@qq.com ; Thank landlord

------ For reference only ---------------------------------- -----

issued
------ For reference only ------------------------ ---------------

issued
------ For reference only -------------- -------------------------
good landlord seeking 1037449725@qq.com
------ For reference source only ---------------------------------------

issued < br> ------ For reference only ---------------------------------------
seeking lz code now learning , looking for a long time, thank you. 2637313911@qq.com
------ For reference only --------------------------------- ------

issued
------ For reference only ----------------------- ----------------
landlord cattle b also send me a copy of it my little understanding of the framework , they did not take the initiative configured add QQ best 597494570@qq.com
------ For reference only --------------------------- ------------

issued
------ For reference only ----------------- ----------------------
273731580@qq.com seeking a source , thank landlord , learn about
------ For reference only ---------------------------------------

has Send
------ For reference only ------------------------------------- -
please send me, thank you
zyh5540@163.com
------ For reference only ----------------------------- ----------
good, the interface is very beautiful yo.
------ For reference only -------------------------------------- -
iexwy@126.com seeking source

------ For reference only ---------------------------------- -----
lsl122576652@163.com good landlord , good life of peace , seeking source, thank you !
------ For reference only -------------------------------------- -
landlord , you do nice demo , could trouble landlord also gave me a copy ? My mail is 1467477176@qq.com thank .....
------ For reference only ----------------- ----------------------

issued
------ For reference only ------- --------------------------------

issued
------ For reference only ---------------------------------------

has Send
------ For reference only ------------------------------------- -
landlord really great guy , 3Q very much!
------ For reference only ---------------------- -----------------
.
You're welcome, common learning
------ For reference only ----------------------------- ----------

issued  


good landlord , my mailbox , " wood " received the source code of your hair ah ! is not sent to the wrong mailbox ?
------ For reference only -------------------------------------- -

issued          
  
  
good landlord , my mailbox , " wood " received the source code of your hair ah ! is not sent to the wrong mailbox ?  
reissued
------ For reference only ------------------------------- --------
a copy to 0101wangsy@163.com Thank you.
------ For reference only -------------------------------------- -
good, oh
------ For reference only ---------------------------------------
landlord made source chant ! ! ! 1027060531@qq.com Thank
------ For reference only -------------------------------- -------
nice!!! seek source 515615321@qq.com 3 grams of oil ah
------ For reference only ------------------------------------ ---
synchronization source , longcpp@gmail.com
------ For reference only ------------------------ ---------------
witness , the landlord can send a source, thank you ! 506669624@qq.com
------ For reference only --------------------------------- ------
landlord is a good man ah , find the source !
805182558@qq.com
------ For reference only ----------------------------- ----------
good landlord
1906439128@qq.com
------ For reference only ----------------------------- ----------

issued
------ For reference only ------------------- --------------------

issued
------ For reference only --------- ------------------------------

issued
------ For reference only ---------------------------------------
landlord please, send it, 948732473@qq.com
------ For reference only --------------------------------- ------
good landlord 2604521350@qq.com
------ For reference only -------------------- -------------------

issued
------ For reference only ---------- -----------------------------

issued
------ For reference only ---------------------------------------

issued

------ For reference only ---------------------------------- -----
landlord , you can send to the source of it? 765656959@qq.com In this extremely grateful ! ! !
------ For reference only -------------------------------------- -

issued
------ For reference only ---------------------------- -----------
landlord , you can send to the source of it? 494322596@qq.com In this extremely grateful ! ! !
------ For reference only -------------------------------------- -

issued
------ For reference only ---------------------------- -----------
landlord Hello , I also want to learn next . 913221173@qq.com. Thank
------ For reference only ------------------------------------- -

issued

没有评论:

发表评论