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

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

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

    2012年6月29日

    最近寫了個項目,自己第一次搭建架構,費了好久才搭成功,記錄下來,為以后留個參考。
    前臺使用的是jquery
    web.xml 
     2   <context-param>
     3     <param-name>contextConfigLocation</param-name>
     4         <param-value>
     5           classpath*:applicationContext-common.xml, 
     6           classpath*:applicationContext-dao.xml,
     7           classpath*:applicationContext-service.xml,
     8           classpath*:applicationContext-action.xml
     9         </param-value>
    10   </context-param>
    11   
    12   <welcome-file-list>
    13     <welcome-file>login.jsp</welcome-file>
    14   </welcome-file-list>
    15   <filter>
    16         <filter-name>struts2</filter-name>
    17         <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    18   </filter>
    19   
    20     <filter-mapping>
    21         <filter-name>struts2</filter-name>
    22         <url-pattern>/*</url-pattern>
    23     </filter-mapping>
    24         <listener>
    25         <listener-class>
    26             org.springframework.web.context.ContextLoaderListener 
    27         </listener-class>
    28     </listener>
    29     <session-config> 
    30         <session-timeout>20</session-timeout> 
    31     </session-config>
    32     <filter>
    33        <filter-name>struts-cleanup</filter-name>
    34        <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
    35     </filter>
    36     <filter-mapping>
    37        <filter-name>struts-cleanup</filter-name>
    38        <url-pattern>/*</url-pattern>
    39     </filter-mapping>

    struts.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd"
    >

    <struts>
        <package name="default" namespace="/com" extends="struts-default">
           
            <action name="login" class="loginAction" method="login">
                <result name="success">/main.jsp</result>
                <result name="error">/loginError.jsp</result>
                <result name="fail">/error.jsp</result>
            </action>
            <action name="logoff" class="logoffAction" method="logoff">
                <result name="success" type="redirect">/login.jsp</result> 
            </action>
        </package>
    </struts>

    applicationContext-xxx.xml下面這四個其實可以放在一個配置檔里,區分下來只是為了便于查找清晰點

    applicationContext-action.xml
    1 <bean id="loginAction" class="com.ivo.action.LoginAction" scope="prototype">
    2         <property name="checkAuthorityService" ref="checkAuthorityService" />
    3     </bean>

    applicationContext-service.xml
    1  <bean id="checkAuthorityService" class="com.ivo.service.impl.CheckAuthorityService">
    2         <property name="uasUserDao" ref="uasUserDao" />
    3     </bean>    

    applicationContext-dao.xml
    1 <bean id="uasUserDao" class="com.ivo.dao.impl.UasUserDao">
    2         <property name="sqlMapClient" ref="sqlMapClient" />
    3     </bean>

    applicationCtontext-common.xml
     1 <bean id="mySqlDataSource"
     2         class="org.springframework.jdbc.datasource.DriverManagerDataSource">
     3         <property name="driverClassName">
     4             <value>com.mysql.jdbc.Driver</value>
     5         </property>
     6         <property name="url">
     7             <value>
     8                 jdbc:mysql://10.20.53.106:3306/qrademo
     9             </value>
    10         </property>
    11         <property name="username">
    12             <value>root</value>
    13         </property>
    14         <property name="password">
    15             <value>Ivo123</value>
    16         </property>
    17     </bean>
    18 <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
    19         <property name="configLocation">
    20             <value>classpath:ibatis-config.xml</value>
    21         </property>
    22         <property name="dataSource">
    23             <ref local="mySqlDataSource" />
    24         </property>
    25     </bean>

    ibatis-config.xml
    1 <sqlMapConfig>
    2     <settings cacheModelsEnabled="true" enhancementEnabled="true" lazyLoadingEnabled="true"
    3         maxRequests="300" maxSessions="200" maxTransactions="100" useStatementNamespaces="true" />
    4
       <sqlMap resource="com/ivo/pojo/xml/UasUser.xml" />
    5 </sqlMapConfig>

    差不多建這些,當然還有許多jar包需要導



    posted @ 2012-06-29 19:28 幻破 閱讀(116) | 評論 (0)編輯 收藏
     
    最近寫了個功能jqgrid的某個欄位下載文件,本來直接用<a href=""/>直接鏈接的,但是出現了文件名含中文的就報錯的現象,且若文件類型為.txt則直接打開。然后我糾結啊!
    然后百度到網上有人使用struts2下載文件解決了這個問題,然后就借用了看看。
    jquery代碼
     1 function rangFun(value, options, rData){
     2           return '<a href=entCom/download.action?filename='+rData['range_id']+'>'+rData['range_id']+'</a>';
     3      }
     4  $("#externalListGrd").jqGrid({
     5          datatype    : "json",
     6          mtype       : "POST",
     7          width       : 720 ,
     8          height      : 420,
     9          rownumWidth : true,
    10          shrinkToFit : false,
    11          scroll      : true,
    12         ondblClickRow:regectExtFun,
    13          colNames    : ['允許范圍'],
    14          colModel:[
    15             { name : 'range_id',   index : 'range_id',   width : 50, align: "left",sortable : "true",formatter:rangFun}]
    16    })

    struts.xml里的配置
    1 <action name="download" class="com.ivo.action.DownloadAction">
    2            <result name="success" type="stream">
    3               <param name="contentType">text/html,application/vnd.ms-powerpoint,application/vnd.ms-word,application/vnd.ms-excel,text/plain</param> //文件打開方式
    4               <param name="inputName">inputStream</param>
    5               <param name="contentDisposition">attachment;filename="${filename}"</param>
    6               <param name="bufferSize">2048</param>
    7            </result>
    8         </action>

    后臺代碼
     1 package com.ivo.action;
     2 
     3 import java.io.FileInputStream;
     4 import java.io.InputStream;
     5 import java.io.UnsupportedEncodingException;
     6 
     7 import com.opensymphony.xwork2.ActionSupport;
     8 
     9 public class DownloadAction extends ActionSupport {
    10    private String filename;
    11    public InputStream getInputStream() throws Exception{
    12        String downloadFileName=filename;
    13         try {
    14             // downloadFileName = new String(downloadFileName.getBytes(),"UTF-8");這樣帶中文名的文件依舊會報錯,想了半天找前輩幫忙看,后來改成下面的才OK。原因是從前臺傳過來的時候字符已經亂碼,所以需要重新解析,再轉換
    15             downloadFileName = new String(downloadFileName.getBytes("ISO-8859-1"),"UTF-8");
    16 
    17         } catch(UnsupportedEncodingException e) {
    18 
    19             e.printStackTrace();
    20 
    21         }
    22        String dir = "D:\\qra\\fileUpload\\"+downloadFileName;
    23        return new FileInputStream(dir);
    24    }
    25 
    26     public String getFilename() {
    27         return filename;
    28     }
    29 
    30     public void setFilename(String filename) {
    31         this.filename = filename;
    32     }
    33    
    34 }



    posted @ 2012-06-29 19:08 幻破 閱讀(181) | 評論 (0)編輯 收藏

    2012年2月13日

    最近遇到這種問題,相當煩惱。還好網上有個解決方法不錯,copy過來自己保留著。
    不過我是在rem Guess CATALINA_HOME if not defined后面添加的set JAVA_OPTS=-Xms64m -Xmx256m -XX:PermSize=128M -XX:MaxNewSize=256m -XX:MaxPermSize=256m
    鏈接地址:
    http://blog.sina.com.cn/s/blog_3caf06b20100czvo.html 
    posted @ 2012-02-13 09:23 幻破 閱讀(138) | 評論 (0)編輯 收藏

    2012年2月8日

    $(function() {
    var dates = $( "#from, #to" ).datepicker({
    defaultDate: "+1w",/*當前時間加一周*/
    dateFormat: 'yy-mm-dd',//日期格式
    changeMonth: true,
    changeYear:true, //可選擇年份
    numberOfMonths: 1,//設置一次顯示幾個月
    onSelect: function( selectedDate ) {
    var option = this.id == "from" ? "minDate" : "maxDate",
    instance = $( this ).data( "datepicker" ),
    date = $.datepicker.parseDate(
    instance.settings.dateFormat ||
    $.datepicker._defaults.dateFormat,
    selectedDate, instance.settings );     //還沒搞懂?
    dates.not( this ).datepicker( "option", option, date );
    }
    });
    });

    posted @ 2012-02-08 18:51 幻破 閱讀(202) | 評論 (0)編輯 收藏
    僅列出標題  
     
    主站蜘蛛池模板: 18禁无遮挡无码网站免费| 亚洲码国产精品高潮在线| 18亚洲男同志videos网站| 亚洲一区二区三区四区视频| 国色精品va在线观看免费视频| 免费a级毛片18以上观看精品| 亚洲国产成人久久精品大牛影视 | 1000部拍拍拍18勿入免费视频软件 | 中文字幕不卡免费视频| 中文字幕亚洲天堂| 亚洲乱亚洲乱淫久久| 午夜不卡久久精品无码免费| 成人黄软件网18免费下载成人黄18免费视频| 亚洲国产精品婷婷久久| 亚洲毛片免费观看| 亚洲色偷偷偷综合网| 暖暖在线日本免费中文| 男人免费视频一区二区在线观看| 亚洲一区二区三区在线视频| 国产猛男猛女超爽免费视频| 67pao强力打造67194在线午夜亚洲| 精品香蕉在线观看免费| 无码天堂亚洲国产AV| 亚洲人成无码网站| 91免费资源网站入口| 国产成人亚洲综合无| 久久亚洲国产精品一区二区| 无码国产精品一区二区免费式直播| 亚洲熟妇自偷自拍另欧美| 亚洲精品视频免费观看| 日本免费中文字幕| 伊人亚洲综合青草青草久热| 菠萝菠萝蜜在线免费视频| 免费毛片在线播放| 精品久久久久久无码免费| 亚洲成人黄色网址| 亚洲国产精品不卡毛片a在线| 99热免费在线观看| 羞羞视频免费观看| 亚洲精品国产手机| 亚洲一区二区三区乱码A|