<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 59, comments - 244, trackbacks - 0, articles - 0
      BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

    spring mvc注解例子

    Posted on 2010-11-28 01:37 penngo 閱讀(130706) 評(píng)論(55)  編輯  收藏 所屬分類: Java
     棄用了struts,用spring mvc框架做了幾個(gè)項(xiàng)目,感覺(jué)都不錯(cuò),而且使用了注解方式,可以省掉一大堆配置文件。本文主要介紹使用注解方式配置的spring mvc,之前寫的spring3.0 mvc和rest小例子沒(méi)有介紹到數(shù)據(jù)層的內(nèi)容,現(xiàn)在這一篇補(bǔ)上。下面開(kāi)始貼代碼。

    文中用的框架版本:spring 3,hibernate 3,沒(méi)有的,自己上網(wǎng)下。

    web.xml配置:

    <?xml version="1.0" encoding="UTF-8"?>   
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">   
      
    <display-name>s3h3</display-name>   
       
    <context-param>     
         
    <param-name>contextConfigLocation</param-name>     
         
    <param-value>classpath:applicationContext*.xml</param-value>     
     
    </context-param>     
      
    <listener>     
         
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>     
     
    </listener>     
      
     
    <servlet>     
         
    <servlet-name>spring</servlet-name>     
         
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>     
         
    <load-on-startup>1</load-on-startup>     
     
    </servlet>     
     
    <servlet-mapping>     
         
    <servlet-name>spring</servlet-name>  <!-- 這里在配成spring,下邊也要寫一個(gè)名為spring-servlet.xml的文件,主要用來(lái)配置它的controller -->   
         
    <url-pattern>*.do</url-pattern>     
     
    </servlet-mapping>     
      
    <welcome-file-list>   
        
    <welcome-file>index.jsp</welcome-file>   
      
    </welcome-file-list>   
    </web-app>  

    spring-servlet,主要配置controller的信息

    <?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:context
    ="http://www.springframework.org/schema/context"     
       xsi:schemaLocation
    ="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd   
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd   
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd   
           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
    >   
         
      
    <context:annotation-config />   
           
    <!-- 把標(biāo)記了@Controller注解的類轉(zhuǎn)換為bean -->     
          
    <context:component-scan base-package="com.mvc.controller" />     
      
    <!-- 啟動(dòng)Spring MVC的注解功能,完成請(qǐng)求和注解POJO的映射 -->     
          
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />     
            
           
    <!-- 對(duì)模型視圖名稱的解析,即在模型視圖名稱添加前后綴 -->     
           
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"     
              p:prefix
    ="/WEB-INF/view/" p:suffix=".jsp" />     
               
           
    <bean id="multipartResolver"     
              class
    ="org.springframework.web.multipart.commons.CommonsMultipartResolver"     
              p:defaultEncoding
    ="utf-8" />     
     
    </beans>  

    applicationContext.xml代碼

    <?xml version="1.0" encoding="UTF-8"?>   
    <beans xmlns="http://www.springframework.org/schema/beans"  
     xmlns:aop
    ="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"  
     xmlns:p
    ="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"  
     xmlns:xsi
    ="http://www.w3.org/2001/XMLSchema-instance"  
     xsi:schemaLocation
    ="   
             http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd   
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd   
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd   
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"
    >   
      
     
    <context:annotation-config />   
     
    <context:component-scan base-package="com.mvc" />  <!-- 自動(dòng)掃描所有注解該路徑 -->   
      
     
    <context:property-placeholder location="classpath:/hibernate.properties" />   
      
     
    <bean id="sessionFactory"  
      class
    ="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">   
      
    <property name="dataSource" ref="dataSource" />   
      
    <property name="hibernateProperties">   
       
    <props>   
        
    <prop key="hibernate.dialect">${dataSource.dialect}</prop>   
        
    <prop key="hibernate.hbm2ddl.auto">${dataSource.hbm2ddl.auto}</prop>   
        
    <prop key="hibernate.hbm2ddl.auto">update</prop>   
       
    </props>   
      
    </property>   
      
    <property name="packagesToScan">   
       
    <list>   
        
    <value>com.mvc.entity</value><!-- 掃描實(shí)體類,也就是平時(shí)所說(shuō)的model -->   
       
    </list>   
        
    </property>   
     
    </bean>   
      
     
    <bean id="transactionManager"  
      class
    ="org.springframework.orm.hibernate3.HibernateTransactionManager">   
      
    <property name="sessionFactory" ref="sessionFactory" />   
      
    <property name="dataSource" ref="dataSource" />   
     
    </bean>   
      
     
    <bean id="dataSource"  
      class
    ="org.springframework.jdbc.datasource.DriverManagerDataSource">   
      
    <property name="driverClassName" value="${dataSource.driverClassName}" />   
      
    <property name="url" value="${dataSource.url}" />   
      
    <property name="username" value="${dataSource.username}" />   
      
    <property name="password" value="${dataSource.password}" />   
     
    </bean>   
     
    <!-- Dao的實(shí)現(xiàn) -->   
     
    <bean id="entityDao" class="com.mvc.dao.EntityDaoImpl">     
      
    <property name="sessionFactory" ref="sessionFactory" />   
     
    </bean>   
     
    <tx:annotation-driven transaction-manager="transactionManager" />   
     
    <tx:annotation-driven mode="aspectj"/>   
         
        
    <aop:aspectj-autoproxy/>     
    </beans>  

    hibernate.properties數(shù)據(jù)庫(kù)連接配置

    dataSource.password=123  
    dataSource.username=root   
    dataSource.databaseName=test   
    dataSource.driverClassName=com.mysql.jdbc.Driver   
    dataSource.dialect=org.hibernate.dialect.MySQL5Dialect   
    dataSource.serverName=localhost:3306  
    dataSource.url=jdbc:mysql://localhost:3306/test   
    dataSource.properties=user=${dataSource.username};databaseName=${dataSource.databaseName};serverName=${dataSource.serverName};password=${dataSource.password}   
    dataSource.hbm2ddl.auto=update  

    配置已經(jīng)完成,下面開(kāi)始例子
    先在數(shù)據(jù)庫(kù)建表,例子用的是mysql數(shù)據(jù)庫(kù)

    CREATE TABLE  `test`.`student` (   
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,   
      `name` varchar(45) NOT NULL,   
      `psw` varchar(45) NOT NULL,   
      PRIMARY KEY (`id`)   
    )  

    建好表后,生成實(shí)體類

    package com.mvc.entity;   
      
    import java.io.Serializable;   
      
    import javax.persistence.Basic;   
    import javax.persistence.Column;   
    import javax.persistence.Entity;   
    import javax.persistence.GeneratedValue;   
    import javax.persistence.GenerationType;   
    import javax.persistence.Id;   
    import javax.persistence.Table;   
      
    @Entity  
    @Table(name = "student")   
    public class Student implements Serializable {   
        private static final long serialVersionUID = 1L;   
        @Id  
        @Basic(optional = false)   
        @GeneratedValue(strategy = GenerationType.IDENTITY)   
        @Column(name = "id", nullable = false)   
        private Integer id;   
        @Column(name = "name")   
        private String user;   
        @Column(name = "psw")   
        private String psw;   
        public Integer getId() {   
            return id;   
        }   
        public void setId(Integer id) {   
            this.id = id;   
        }   
           
        public String getUser() {   
            return user;   
        }   
        public void setUser(String user) {   
            this.user = user;   
        }   
        public String getPsw() {   
            return psw;   
        }   
        public void setPsw(String psw) {   
            this.psw = psw;   
        }   
    }  

    Dao層實(shí)現(xiàn)
    package com.mvc.dao;   
      
    import java.util.List;   
      
    public interface EntityDao {   
        
    public List<Object> createQuery(final String queryString);   
        
    public Object save(final Object model);   
        
    public void update(final Object model);   
        
    public void delete(final Object model);   
    }
      

    package com.mvc.dao;   
      
    import java.util.List;   
      
    import org.hibernate.Query;   
    import org.springframework.orm.hibernate3.HibernateCallback;   
    import org.springframework.orm.hibernate3.support.HibernateDaoSupport;   
      
    public class EntityDaoImpl extends HibernateDaoSupport implements EntityDao{   
        
    public List<Object> createQuery(final String queryString) {   
            
    return (List<Object>) getHibernateTemplate().execute(   
                    
    new HibernateCallback<Object>() {   
                        
    public Object doInHibernate(org.hibernate.Session session)   
                                
    throws org.hibernate.HibernateException {   
                            Query query 
    = session.createQuery(queryString);   
                            List
    <Object> rows = query.list();   
                            
    return rows;   
                        }
       
                    }
    );   
        }
       
        
    public Object save(final Object model) {   
            
    return  getHibernateTemplate().execute(   
                    
    new HibernateCallback<Object>() {   
                        
    public Object doInHibernate(org.hibernate.Session session)   
                                
    throws org.hibernate.HibernateException {   
                            session.save(model);   
                            
    return null;   
                        }
       
                    }
    );   
        }
       
        
    public void update(final Object model) {   
            getHibernateTemplate().execute(
    new HibernateCallback<Object>() {   
                
    public Object doInHibernate(org.hibernate.Session session)   
                        
    throws org.hibernate.HibernateException {   
                    session.update(model);   
                    
    return null;   
                }
       
            }
    );   
        }
       
        
    public void delete(final Object model) {   
            getHibernateTemplate().execute(
    new HibernateCallback<Object>() {   
                
    public Object doInHibernate(org.hibernate.Session session)   
                        
    throws org.hibernate.HibernateException {   
                    session.delete(model);   
                    
    return null;   
                }
       
            }
    );   
        }
       
    }
      

    Dao在applicationContext.xml注入
    <bean id="entityDao" class="com.mvc.dao.EntityDaoImpl">  
      
    <property name="sessionFactory" ref="sessionFactory" />
     
    </bean>


    Dao只有一個(gè)類的實(shí)現(xiàn),直接供其它service層調(diào)用,如果你想更換為其它的Dao實(shí)現(xiàn),也只需修改這里的配置就行了。
    開(kāi)始寫view頁(yè)面,WEB-INF/view下新建頁(yè)面student.jsp,WEB-INF/view這路徑是在spring-servlet.xml文件配置的,你可以配置成其它,也可以多個(gè)路徑。student.jsp代碼

    <%@ page language="java" contentType="text/html; charset=UTF-8"  
        pageEncoding
    ="UTF-8"
    %>  
    <%@ include file="/include/head.jsp"%>  
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  
    <html>  
    <head>  
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
    <title>添加</title>  
    <script language="javascript" src="<%=request.getContextPath()%><!--   
    /script/jquery.min.js"
    >  
    // --></script>  
    <style><!--   
    table
    {  border-collapse:collapse;  }   
    td
    {  border:1px solid #f00;  }   
    --></style><style mce_bogus="1">table{  border-collapse:collapse;  }   
    td
    {  border:1px solid #f00;  }</style>  
    <script type="text/javascript"><!--   
    function add(){   
        window.location.href
    ="<%=request.getContextPath() %>/student.do?method=add";   
    }
       
      
    function del(id){   
    $.ajax( 
    {   
        type : 
    "POST",   
        url : 
    "<%=request.getContextPath()%>/student.do?method=del&id=" + id,   
        dataType: 
    "json",   
        success : 
    function(data) {   
            
    if(data.del == "true"){   
                alert(
    "刪除成功!");   
                $(
    "#" + id).remove();   
            }
       
            
    else{   
                alert(
    "刪除失敗!");   
            }
       
        }
    ,   
        error :
    function(){   
            alert(
    "網(wǎng)絡(luò)連接出錯(cuò)!");   
        }
       
    }
    );   
    }
       
    // --></script>  
    </head>  
    <body>  
      
    <input id="add" type="button" onclick="add()" value="添加"/>  
    <table >  
        
    <tr>  
            
    <td>序號(hào)</td>  
            
    <td>姓名</td>  
            
    <td>密碼</td>  
            
    <td>操作</td>  
        
    </tr>  
        
    <c:forEach items="${list}" var="student">  
        
    <tr id="<c:out value="${student.id}"/>">  
            
    <td><c:out value="${student.id}"/></td>  
            
    <td><c:out value="${student.user}"/></td>  
            
    <td><c:out value="${student.psw}"/></td>  
            
    <td>  
                
    <input type="button" value="編輯"/>        
                
    <input type="button" onclick="del('<c:out value="${student.id}"/>')" value="刪除"/>  
            
    </td>  
        
    </tr>  
        
    </c:forEach>  
           
    </table>  
    </body>  
    </html>  

    student_add.jsp

    <%@ page language="java" contentType="text/html; charset=UTF-8"  
        pageEncoding
    ="UTF-8"
    %>  
    <%@ include file="/include/head.jsp"%>  
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  
    <html>  
    <head>  
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
    <title>學(xué)生添加</title>  
    <mce:script type="text/javascript"><!--   
    function turnback(){   
        window.location.href="<%=request.getContextPath() %>/student.do";   
    }   
    // 
    --></mce:script>  
    </head>  
    <body>  
    <form method="post" action="<%=request.getContextPath() %>/student.do?method=save">  
    <div><c:out value="${addstate}"></c:out></div>  
    <table>  
        
    <tr><td>姓名</td><td><input id="user" name="user" type="text" /></td></tr>  
        
    <tr><td>密碼</td><td><input id="psw" name="psw"  type="text" /></td></tr>  
        
    <tr><td colSpan="2" align="center"><input type="submit" value="提交"/><input type="button" onclick="turnback()" value="返回" /> </td></tr>  
    </table>  
      
    </form>  
    </body>  
    </html>  

    controller類實(shí)現(xiàn),只需把注解寫上,spring就會(huì)自動(dòng)幫你找到相應(yīng)的bean,相應(yīng)的注解標(biāo)記意義,不明白的,可以自己查下@Service,@Controller,@Entity等等的內(nèi)容。

    package com.mvc.controller;   
      
    import java.util.List;   
      
    import javax.servlet.http.HttpServletRequest;   
    import javax.servlet.http.HttpServletResponse;   
      
    import org.apache.commons.logging.Log;   
    import org.apache.commons.logging.LogFactory;   
    import org.springframework.beans.factory.annotation.Autowired;   
    import org.springframework.stereotype.Controller;   
    import org.springframework.ui.ModelMap;   
    import org.springframework.web.bind.annotation.RequestMapping;   
    import org.springframework.web.bind.annotation.RequestMethod;   
    import org.springframework.web.bind.annotation.RequestParam;   
    import org.springframework.web.servlet.ModelAndView;   
      
    import com.mvc.entity.Student;   
    import com.mvc.service.StudentService;   
      
    @Controller  
    @RequestMapping(
    "/student.do")   
    public class StudentController {   
        
    protected final transient Log log = LogFactory   
        .getLog(StudentController.
    class);   
        @Autowired  
        
    private StudentService studentService;   
        
    public StudentController(){   
               
        }
       
           
        @RequestMapping  
        
    public String load(ModelMap modelMap){   
            List
    <Object> list = studentService.getStudentList();   
            modelMap.put(
    "list", list);   
            
    return "student";   
        }
       
           
        @RequestMapping(params 
    = "method=add")   
        
    public String add(HttpServletRequest request, ModelMap modelMap) throws Exception{   
            
    return "student_add";   
        }
       
           
        @RequestMapping(params 
    = "method=save")   
        
    public String save(HttpServletRequest request, ModelMap modelMap){   
            String user 
    = request.getParameter("user");   
            String psw 
    = request.getParameter("psw");   
            Student st 
    = new Student();   
            st.setUser(user);   
            st.setPsw(psw);   
            
    try{   
                studentService.save(st);   
                modelMap.put(
    "addstate""添加成功");   
            }
       
            
    catch(Exception e){   
                log.error(e.getMessage());   
                modelMap.put(
    "addstate""添加失敗");   
            }
       
               
            
    return "student_add";   
        }
       
           
        @RequestMapping(params 
    = "method=del")   
        
    public void del(@RequestParam("id") String id, HttpServletResponse response){   
            
    try{   
                Student st 
    = new Student();   
                st.setId(Integer.valueOf(id));   
                studentService.delete(st);   
                response.getWriter().print(
    "{\"del\":\"true\"}");   
            }
       
            
    catch(Exception e){   
                log.error(e.getMessage());   
                e.printStackTrace();   
            }
       
        }
       
    }
      

    service類實(shí)現(xiàn)

    package com.mvc.service;   
      
    import java.util.List;   
      
    import org.springframework.beans.factory.annotation.Autowired;   
    import org.springframework.stereotype.Service;   
    import org.springframework.transaction.annotation.Transactional;   
      
    import com.mvc.dao.EntityDao;   
    import com.mvc.entity.Student;   
      
    @Service  
    public class StudentService {   
     @Autowired  
     
    private EntityDao entityDao;   
        
     @Transactional  
     
    public List<Object> getStudentList(){   
      StringBuffer sff 
    = new StringBuffer();   
      sff.append(
    "select a from ").append(Student.class.getSimpleName()).append(" a ");   
      List
    <Object> list = entityDao.createQuery(sff.toString());   
      
    return list;   
     }
       
        
     
    public void save(Student st){   
      entityDao.save(st);   
     }
       
     
    public void delete(Object obj){   
      entityDao.delete(obj);   
     }
       
    }
     

    OK,例子寫完。有其它業(yè)務(wù)內(nèi)容,只需直接新建view,并實(shí)現(xiàn)相應(yīng)comtroller和service就行了,配置和dao層的內(nèi)容基本不變,也就是每次只需寫jsp(view),controller和service調(diào)用dao就行了。

    怎樣,看了這個(gè),spring mvc是不是比ssh實(shí)現(xiàn)更方便靈活。


    完整源碼:srping mvc注解實(shí)現(xiàn)(在這篇文章的后面附件,這個(gè)是我另一個(gè)博客的地址)

    評(píng)論

    # re: spring mvc注解實(shí)現(xiàn)[未登錄](méi)  回復(fù)  更多評(píng)論   

    2010-11-28 12:03 by hijackwust
    您好,最后的源碼鏈接無(wú)法下載。。

    # re: spring mvc注解實(shí)現(xiàn)  回復(fù)  更多評(píng)論   

    2010-11-28 13:22 by pengo
    @hijackwust
    地址已改過(guò)來(lái)了,需要學(xué)習(xí)的,自己下載。附件的代碼是我在eclipse3.5下寫的。

    # re: spring mvc注解實(shí)現(xiàn)[未登錄](méi)  回復(fù)  更多評(píng)論   

    2010-11-28 14:37 by hijackwust
    MVC注解的國(guó)際化怎么弄?

    # re: spring mvc注解實(shí)現(xiàn)[未登錄](méi)  回復(fù)  更多評(píng)論   

    2010-11-28 14:51 by hijackwust
    為什么我使用SpringMVC3時(shí)頁(yè)面不支持EL表達(dá)式,而你的頁(yè)面就可以?

    還有 用MVC注解做驗(yàn)證時(shí)候的國(guó)際化,您是如何處理的?
    最近我也在學(xué)習(xí)SpringMVC,所以問(wèn)了這么多問(wèn)題。

    # re: spring mvc注解實(shí)現(xiàn)  回復(fù)  更多評(píng)論   

    2010-11-28 19:09 by pengo
    @hijackwust
    你的頁(yè)面不支持EL表達(dá)式,應(yīng)該是有地方寫錯(cuò)了,你自己對(duì)比下哪里寫錯(cuò)。
    “MVC注解做驗(yàn)證時(shí)候的國(guó)際化”,這個(gè)現(xiàn)在未用過(guò),也不知。

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2010-12-13 12:39 by pandora jewelry
    spring 3,hibernate 3,沒(méi)有的,自己上網(wǎng)下。

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2011-03-08 16:16 by jumkey
    你好,請(qǐng)教一下<c:out value="${student.id}"/>跟${student.id}有什么區(qū)別嗎?

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2011-03-08 22:06 by penngo
    <c:out value="${student.id}"/>是jstl的標(biāo)簽,具體用法可以自己查下jstl。

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2011-06-14 17:39 by willian
    有個(gè)問(wèn)題請(qǐng)教一下。Dao這個(gè)部分為什么需要單獨(dú)定義,注解Dao后再自動(dòng)掃描不可以么?在Dao比較多的情況下,這種定義的方式也是挺煩的。

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2011-06-23 23:25 by penngo
    @willian
    因?yàn)槿恐挥幸粋€(gè)通用的DAO,所以單獨(dú)定義比較好,這是為了以后更換DAO的方便。

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2011-08-25 13:59 by java zz
    能不能把這個(gè)demo發(fā)我一下
    894571429@qq.com
    如果能萬(wàn)分感謝

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2011-09-12 17:12 by 來(lái)如風(fēng)
    請(qǐng)問(wèn)spring mvc 的view 路徑支持 像struts2 的namespace這種么,比如說(shuō),如果是userController 就自動(dòng)去/web-inf/views/user/ 路徑下找對(duì)應(yīng)的文件,所有jsp放在同一個(gè)目錄下也挺煩人的

    # re: spring mvc注解例子[未登錄](méi)  回復(fù)  更多評(píng)論   

    2011-10-29 11:01 by spring
    請(qǐng)問(wèn),controller 中的load方法是如何被調(diào)用的

    # re: spring mvc注解例子[未登錄](méi)  回復(fù)  更多評(píng)論   

    2011-10-29 11:04 by spring
    http://localhost:8080/工程名/student.do
    就能進(jìn)入到controller里面的load方法嗎,沒(méi)明白

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2011-11-10 16:29 by austenliao
    說(shuō)明一下,為什么還保留使用hibernate

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2011-12-03 11:55 by tkreal
    不好意思,我是新手,請(qǐng)問(wèn)源碼導(dǎo)入eclipse以后,如何運(yùn)行啊?
    注:tomcat等已經(jīng)配置好了。

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2011-12-18 19:06 by 上的
    不錯(cuò)昂。

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2012-01-10 12:29 by yong230
    沒(méi)有修改啊!

    # 2  回復(fù)  更多評(píng)論   

    2012-02-23 17:36 by 3
    <script>alert('')</script>

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2012-02-27 09:26 by 六六
    整個(gè)項(xiàng)目報(bào)錯(cuò)啊,部署不了,但類和頁(yè)面沒(méi)有報(bào)錯(cuò)

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2012-03-05 11:20 by hah
    給的不全害死人啊!!!

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2012-03-09 21:36 by Kent160
    數(shù)據(jù)庫(kù)沒(méi)給啊?

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2012-03-09 21:38 by Kent160
    哦,看錯(cuò)了。不好意思!

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2012-04-10 15:15 by testssssssssssssssssssssssssssssssssssssssssssssss
    hehe . hai bu cuo ...

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2012-04-27 13:23 by buddha
    java spring jpa android技術(shù)交流QQ群122674573

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2012-05-08 09:59 by gwb
    你的項(xiàng)目不能正常的跑起來(lái)

    # re: spring mvc注解例子[未登錄](méi)  回復(fù)  更多評(píng)論   

    2012-05-18 14:05 by 石頭
    不錯(cuò),,值得收藏

    # 項(xiàng)目部署了,沒(méi)有報(bào)錯(cuò),但是運(yùn)行時(shí)候就報(bào)404錯(cuò)  回復(fù)  更多評(píng)論   

    2012-05-18 17:38 by light.young
    項(xiàng)目部署了,沒(méi)有報(bào)錯(cuò),但是運(yùn)行時(shí)候就報(bào)404錯(cuò),不知道為啥

    # re: spring mvc注解例子[未登錄](méi)  回復(fù)  更多評(píng)論   

    2012-05-24 08:51 by
    請(qǐng)教樓主,我把Service改成接口的方式,然后不用@Autowired ,我用的@Resource 注入,為什么不能用啊? 啟動(dòng)就報(bào)錯(cuò)了。求解?

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2012-09-27 17:09 by 11
    @pengo
    111

    # re: spring mvc注解例子[未登錄](méi)  回復(fù)  更多評(píng)論   

    2012-10-16 15:16 by c
    能不能把這個(gè)demo發(fā)我一下
    402670211@qq.com
    如果能萬(wàn)分感謝

    # re: spring mvc注解例子[未登錄](méi)  回復(fù)  更多評(píng)論   

    2012-10-17 15:39 by vincent
    @penngo
    不錯(cuò)的例子啊

    # re: spring mvc注解例子[未登錄](méi)  回復(fù)  更多評(píng)論   

    2012-10-17 15:39 by vincent
    這里列子不錯(cuò),收藏了

    # re: spring mvc注解例子[未登錄](méi)  回復(fù)  更多評(píng)論   

    2012-11-05 08:35 by zyy
    包·········

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2012-12-10 13:41 by 菜鳥(niǎo)學(xué)習(xí)
    你的el表達(dá)式不能用,可能是需要在jsp頁(yè)面引用jstl標(biāo)簽庫(kù)@hijackwust

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2012-12-12 16:46 by 小兵
    <property name="mappingResources">
    <list>
    <value>com/szhome/*/entity/*.hbm.xml</value>
    配置文件超過(guò)八十個(gè)就會(huì)報(bào)內(nèi)存溢出。。什么問(wèn)題

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2013-01-24 18:36 by 你的承諾
    請(qǐng)問(wèn)有一個(gè)完整的例子嗎?下載地址在哪里?

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2013-01-24 18:37 by 你的承諾
    請(qǐng)把下載的地址公布一下行嗎?謝謝

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2013-04-08 16:58 by suifeng
    @Kent160
    挺不錯(cuò)的

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2013-05-13 15:42 by hasau@163.com
    不能下載啊!!

    有沒(méi)有人貼一份啊!!

    hasau@163.com

    # re: spring mvc注解例子[未登錄](méi)  回復(fù)  更多評(píng)論   

    2013-06-04 14:28 by ivan
    我是初學(xué)者,正好找入門的資料,寫的挺好,下載了!

    # re: spring mvc注解例子[未登錄](méi)  回復(fù)  更多評(píng)論   

    2013-09-21 10:36 by sun
    收藏

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2013-11-20 11:51 by daiweid
    dsfdsfdsf

    # re: spring mvc注解例子[未登錄](méi)  回復(fù)  更多評(píng)論   

    2014-02-10 10:43 by jame
    想法是出來(lái)了,但是dao層不全吧。公共dao層是這樣的,如果要用到其他的方法你不可能都寫在公共的dao層里面撒。新手求教

    # re: spring mvc注解例子[未登錄](méi)  回復(fù)  更多評(píng)論   

    2014-02-12 11:26 by Allen
    內(nèi)容挺全的

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2014-04-11 14:45 by 余小魚(yú)
    怎么下啊

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2014-04-27 00:17 by 最代碼
    請(qǐng)參考代碼: SpringMVC入門教程及其原理講解和實(shí)例代碼下載 ,下載地址:http://www.zuidaima.com/share/1751859714182144.htm

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2014-06-03 10:23 by azaoshu33
    你用的是spring的3.幾版本啊?為什么我一直報(bào)錯(cuò)?

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2014-06-13 10:41 by 小星星
    @pengo
    sff.append("select a from ").append(Student.class.getSimpleName()).append("a");這句話的語(yǔ)句是這么寫嗎 怎么我運(yùn)行的時(shí)候報(bào)錯(cuò)呢

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2014-07-10 17:00 by WF
    使用oracle,一直提示id不能插入null,原來(lái)@GeneratedValue忘記改了,大意了

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2014-07-27 15:34 by 曉明
    @小星星給我發(fā)一份啊,不能下載,郵箱:1635387592@qq.com

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2014-08-04 10:29 by 上海-地瓜
    @jumkey
    c:out十一個(gè)雞肋的標(biāo)簽,基本不用!

    # re: spring mvc注解例子[未登錄](méi)  回復(fù)  更多評(píng)論   

    2015-01-29 15:20 by
    能不能把這個(gè)完整的例子發(fā)給我啊? 303871975@qq.com謝謝了

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2015-05-15 14:53 by xgz
    怎么訪問(wèn)里面的頁(yè)面啊……

    # re: spring mvc注解例子  回復(fù)  更多評(píng)論   

    2016-06-06 11:30 by 黑科技
    是分散
    主站蜘蛛池模板: AV免费网址在线观看| 亚洲一级毛片免费观看| 精品视频一区二区三区免费| 亚洲日韩中文在线精品第一| 五月天婷婷免费视频| 亚洲黄片毛片在线观看| 午夜不卡AV免费| 亚洲视频人成在线播放| 一区二区免费国产在线观看| 国产亚洲精品AA片在线观看不加载| 一个人看的www视频免费在线观看| 亚洲国产91精品无码专区| 人与动性xxxxx免费| 区三区激情福利综合中文字幕在线一区亚洲视频1| 色一情一乱一伦一视频免费看| 免费在线观看黄色毛片| 一级做受视频免费是看美女| 亚洲午夜久久久久久久久久| 久久精品成人免费网站| 在线电影你懂的亚洲| 国产精品怡红院永久免费| 亚洲综合成人婷婷五月网址| 精品国产麻豆免费网站| 免费无码国产V片在线观看| 久久乐国产精品亚洲综合| 手机看片国产免费永久| 久久精品国产亚洲AV无码娇色| 午夜性色一区二区三区免费不卡视频 | 美女被免费视频网站| 亚洲AV无码一区二区三区国产| 一级做a爰片久久毛片免费看 | 国产亚洲精品成人久久网站| 亚洲人成网站色在线入口| 中国一级特黄高清免费的大片中国一级黄色片 | 亚洲一区二区三区免费| 亚洲国产日韩一区高清在线| 思思re热免费精品视频66| 亚洲第一成年免费网站| 亚洲精品无码久久毛片| 可以免费观看的毛片| 亚洲性一级理论片在线观看|