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

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

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

    隨筆-42  評(píng)論-42  文章-0  trackbacks-0

      1 web.xml 文件的配置

      在引入Spring 后,想要建一個(gè)beans.xml作為Spring的配置文件,而不是默認(rèn)的 english-servlet.xml

    web.xml:

    ……

    <servlet>

     <servlet-name>english</servlet-name>

     <servlet-class>org.springframework.web.servlet.DispatcherServlet </servlet-class>

     <init-param>

      <param-name>contextConfigLocation</param-name>

      <param-value>/WEB-INF/beans.xml</param-value>

     </init-param>

     <load-on-startup>1</load-on-startup>

    </servlet>

     

    2 引入tiles時(shí)配置文件的改動(dòng):

    Beans.xml:

      在beans.xml里加入以下<bean>

    <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">

    <property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView" />

    </bean>

    <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">

    <property name="definitions">

    <list>

    <value>/WEB-INF/tiles.xml</value>

    </list>

    </property>

    </bean>

    <bean name="/*.view" class="org.springframework.web.servlet.mvc.UrlFilenameViewController"></bean>

    web.xml加入:

    <servlet-mapping>

    <servlet-name>english</servlet-name>

    <url-pattern>*.view</url-pattern>

    </servlet-mapping>

    tiles.xml文件,并試運(yùn)行

    Tiles.xml:

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"

    "http://tiles.apache.org/dtds/tiles-config_2_0.dtd" >

    <tiles-definitions>

      <definition name=""/>

      <definition name="index" template="/index.jsp"></definition>

    </tiles-definitions>

    運(yùn)行 ,url=“http://localhost:8080/english/index.view”

     

    3 引入hibernate

    (1)除了要有hibernatehibernate_annotation的自身包和lib包外,還要有jdbc的驅(qū)動(dòng)包

    (2)hibernate.cfg.xml的同時(shí)最好把”Create a console configuration”復(fù)選項(xiàng)加上,如果沒有,后來要建”console configuration”則要在hibernate視圖下建。 
     

    4 功能規(guī)劃

     (1table

      1)用戶表english_user id, password, 格言,

      2)英語單詞表english_word  id,name,content,userid,book,class,forExampletime

      3)課文表 id,content,expression(語法),exercise(習(xí)題),time

      4)其它(other)看到的句子,單詞,語法 ,歌詞,電影對(duì)白等等

        id,content,time

      5java專用詞  id,name,content,time


    5 功能
       

    功能 難度 時(shí)間 優(yōu)先級(jí) 一期 二期 三期
    基本功能 1 1 1    
    背單詞(包括定時(shí)提醒)
    2 2 6    
    導(dǎo)入導(dǎo)出到文件 2 2 4    
    專輯單詞表 1 1 2    
    錄放功能 3 3      
    好友(包括引用) 1 1 3    
    用戶積分、聲望(提問、回答) 2 1       ☆ 
    共享(共同翻譯) 1 1 5    

    暫定一期為期7天

    posted on 2008-06-03 02:35 BlueSunshine 閱讀(337) 評(píng)論(7)  編輯  收藏 所屬分類: 學(xué)習(xí)心得

    評(píng)論:
    # re: 建 English 項(xiàng)目遇到的問題 2008-06-03 15:28 | 哈哈的日子
    support
    寫得不錯(cuò),通俗易懂,以后俺就向你學(xué)習(xí)了。  回復(fù)  更多評(píng)論
      
    # re: 建 English 項(xiàng)目遇到的問題 2008-06-04 10:24 | BlueSunshine
    6 Spring 與 Hibernate 的集成

    在 beans.xml 加入: 
    <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
            
    <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
            
    <property name="url" value="jdbc:oracle:thin:@localhost:1521:orcl" />
            
    <property name="username" value="yiqi" />
            
    <property name="password" value="haha" />
        
    </bean>
        
        
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
            
    <property name="dataSource" ref="myDataSource"></property>
            
    <property name="hibernateProperties">
                
    <props>
                    
    <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
                    
    <prop key="hbm2ddl.auto">create</prop>
                    
    <prop key="current_session_context_class">thread</prop>
                
    </props>
            
    </property>
            
    <property name="annotatedClasses">
                
    <list>
                    
    <value>com.english.user.EnglishUser</value>
                    
    <value>com.english.word.EnglishWord</value>
                
    </list>
            
    </property>
        
    </bean>
        
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
            
    <property name="dataSource" ref="myDataSource"></property>
            
    <property name="sessionFactory" ref="sessionFactory"></property>
        
    </bean>
        
    <tx:annotation-driven/>
        
    <context:component-scan base-package="com.english.controller"></context:component-scan>


      回復(fù)  更多評(píng)論
      
    # re: 建 English 項(xiàng)目遇到的問題 2008-06-10 09:24 | BlueSunshine
    7 完成了UserController, UserDAO, UserService 及對(duì)應(yīng)的靜態(tài)頁

    EnglishUserController:
    package com.english.controller;

    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpSession;

    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;

    import com.english.user.EnglishUser;
    import com.english.user.EnglishUserService;
    import com.english.user.LoginException;

    @Controller
    public class EnglishUserController {
        
    //自動(dòng)寫入
        @Autowired
        
    private EnglishUserService englishUserService;

        @RequestMapping(
    "/register.do")
        
    public String addEnglishUser(HttpServletRequest req, EnglishUser englishUser) {
            englishUserService.addEnglishUser(englishUser);
            req.getSession().setAttribute(
    "englishUser", englishUser);
            
    return "index";

        }


        @RequestMapping(
    "/login.do")
        
    public String loginEnglishUser(HttpSession session, EnglishUser englishUser) {
            
    try {
                EnglishUser englishUserTest 
    = englishUserService.vefifyEnglishUser(englishUser);
                session.setAttribute(
    "englishUser", englishUserTest);
                
    return "index";
            }
     catch (LoginException e) {
                
    return "loginFail";
            }

        }


        @RequestMapping(
    "/logout.do")
        
    public String logout(HttpSession session) {
            
    //session.removeAttribute("englishUser");之前寫的是這句,下面的是自己新想出來的
            session.setAttribute("englishUser"null);
            
    return "index";
        }


        
    public EnglishUserService getEnglishUserService() {
            
    return englishUserService;
        }


        
    public void setEnglishUserService(EnglishUserService englishUserService) {
            
    this.englishUserService = englishUserService;
        }

    }


    錯(cuò)誤之一,沒在
    "private EnglishUserService englishUserService"前面加標(biāo)注:
     @autowired   回復(fù)  更多評(píng)論
      
    # re: 建 English 項(xiàng)目遇到的問題 2008-06-10 10:23 | BlueSunshine
    8 “登錄失敗”的問題

    topLogin.jsp:(template 里的 "top" 部分)
    <%@page import="com.english.user.EnglishUser;"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

    <%
        EnglishUser englishUser 
    = (EnglishUser) session.getAttribute("englishUser");
        
    String englishUserId = "游客";
        
    if (englishUser != null)
            englishUserId 
    = englishUser.getUserid();
    %>
    <table background="img/beijing_flower.jpg" width="1024" height="228">
        
    <tr>
            
    <td>Welcome to 'Sunshine zone'!登錄身份:<%=englishUserId%></td>
        
    </tr>
        
    <c:if test="${sessionScope.englishUser!=null}">
            
    <tr>
                
    <td><href="logout.do">logout</a></td>
            
    </tr>
        
    </c:if>
    </table>

    在“登錄失敗”后 "logout" 對(duì)應(yīng)的 <td> 出現(xiàn)在頁面上,問題出在:
    雖然 session 為 null ,但是 request 里面有 englishUser ,所以在同名的情況出錯(cuò)。(為框架沖突)
    解決方法:
    <c:if test="${sessionScope.englishUser!=null}">
    給出范圍,只找session 類型的 englishUser   回復(fù)  更多評(píng)論
      
    # re: 建 English 項(xiàng)目遇到的問題 2008-06-10 14:32 | BlueSunshine
    10 兩表關(guān)連
      第一次用兩到表的關(guān)連,在"word"表里有"userId"這一列,而這列來自表"user"。用 Hibernate 生成的兩個(gè)表對(duì)應(yīng)文件和之前的不同,可能在取值的時(shí)候方便一些,還沒用到,只是想法。

      期待中......  回復(fù)  更多評(píng)論
      
    # re: 建 English 項(xiàng)目遇到的問題 2008-06-10 14:57 | BlueSunshine
    11 表"word"引入 sequence   
      表"word" 的"wordId" 列是自動(dòng)生成的,要用 sequence 。  
      在"word" 表對(duì)應(yīng)的 java 文件中,加入:
    @GeneratedValue(strategy = GenerationType.SEQUENCE)


    -------------下面是結(jié)果


    @Id
        @Column(name 
    = "WORD_ID", nullable = false, precision = 10, scale = 0)
        @GeneratedValue(strategy 
    = GenerationType.SEQUENCE)
        
    public int getWordId() {
            
    return this.wordId;
        }
    這樣就可以了   回復(fù)  更多評(píng)論
      
    # re: 建 English 項(xiàng)目遇到的問題 2008-06-26 22:36 | BlueSunshine
    基本功能補(bǔ)充:

    1 單詞表的分頁;
    2 insert / update 后的定位;
    3 index 頁的動(dòng)態(tài)截選(最后做)  回復(fù)  更多評(píng)論
      
    主站蜘蛛池模板: 亚洲中文字幕乱码AV波多JI| 人妻18毛片a级毛片免费看| 免费看黄的成人APP| 日本免费的一级v一片| 亚洲高清资源在线观看| 国产精品九九久久免费视频 | 四虎免费影院4hu永久免费| 亚洲电影在线免费观看| 在线免费视频你懂的| 免费黄色网址入口| 亚洲性色高清完整版在线观看| 国产性生大片免费观看性| 四虎永久免费观看| 中文文字幕文字幕亚洲色| 99久热只有精品视频免费观看17| 综合亚洲伊人午夜网 | 国产在线a不卡免费视频| 亚洲伊人色一综合网| 国产精品免费无遮挡无码永久视频 | 国产成人精品免费视频大全| 国产精品免费电影| 亚洲综合久久精品无码色欲| 18女人水真多免费高清毛片 | 亚洲综合一区二区国产精品| 国产一级在线免费观看| 亚洲精品无码永久在线观看| 亚洲AV第一成肉网| 免费人成网站在线观看10分钟| 亚洲美女视频免费| 99视频有精品视频免费观看| 亚洲VA成无码人在线观看天堂| 国产日韩久久免费影院| 亚洲国产综合人成综合网站| 真人无码作爱免费视频| 国产美女无遮挡免费视频网站| 亚洲色中文字幕在线播放| 国产成人A在线观看视频免费| 亚洲一级黄色大片| 67194熟妇在线永久免费观看| 亚洲免费二区三区| 免费无码黄十八禁网站在线观看|