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

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

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

    Java Home

    Java技術修煉中...
    posts - 20, comments - 22, trackbacks - 0, articles - 0
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    2007年3月11日

    FreeMarker是一個模板引擎,一個基于模板生成文本輸出的通用工具,使用純Java編寫

    FreeMarker被設計用來生成HTML Web頁面,特別是基于MVC模式的應用程序

    雖然FreeMarker具有一些編程的能力,但通常由Java程序準備要顯示的數據,由FreeMarker生成頁面,通過模板顯示準備的數據

    FreeMarker不是一個Web應用框架,而適合作為Web應用框架一個組件

    FreeMarker與容器無關,因為它并不知道HTTP或Servlet;FreeMarker同樣可以應用于非Web應用程序環境

    FreeMarker更適合作為Model2框架(如Struts)的視圖組件,你也可以在模板中使用JSP標記庫

    FreeMarker是免費的

    1、通用目標

    能夠生成各種文本:HTML、XML、RTF、Java源代碼等等

    易于嵌入到你的產品中:輕量級;不需要Servlet環境

    插件式模板載入器:可以從任何源載入模板,如本地文件、數據庫等等

    你可以按你所需生成文本:保存到本地文件;作為Email發送;從Web應用程序發送它返回給Web瀏覽器

    2、強大的模板語言

    所有常用的指令:include、if/elseif/else、循環結構

    在模板中創建和改變變量

    幾乎在任何地方都可以使用復雜表達式來指定值

    命名的宏,可以具有位置參數和嵌套內容

    名字空間有助于建立和維護可重用的宏庫,或者將一個大工程分成模塊,而不必擔心名字沖突

    輸出轉換塊:在嵌套模板片段生成輸出時,轉換HTML轉義、壓縮、語法高亮等等;你可以定義自己的轉換

    3、通用數據模型

    FreeMarker不是直接反射到Java對象,Java對象通過插件式對象封裝,以變量方式在模板中顯示

    你可以使用抽象(接口)方式表示對象(JavaBean、XML文檔、SQL查詢結果集等等),告訴模板開發者使用方法,使其不受技術細節的打擾

    4、為Web準備

    在模板語言中內建處理典型Web相關任務(如HTML轉義)的結構

    能夠集成到Model2 Web應用框架中作為JSP的替代

    支持JSP標記庫

    為MVC模式設計:分離可視化設計和應用程序邏輯;分離頁面設計員和程序員

    5、智能的國際化和本地化

    字符集智能化(內部使用UNICODE)

    數字格式本地化敏感

    日期和時間格式本地化敏感

    非US字符集可以用作標識(如變量名)

    多種不同語言的相同模板

    6、強大的XML處理能力

    <#recurse> 和<#visit>指令(2.3版本)用于遞歸遍歷XML樹

    在模板中清楚和直覺的訪問XML對象模型

    posted @ 2007-06-19 08:26 Yemoo'S Java Blog 閱讀(497) | 評論 (0)編輯 收藏

    當jsp程序出現異常時,往往是直接輸出到瀏覽器頁面上的,這樣以來,可能使最終用戶感到不知所措,也可能因為暴露服務器某些信息而導致服務器的安全性問題。在jsp里我們可以通過制定errorPage="xxx"以使當程序出現錯誤時轉向指定的錯誤頁面,但如果前期沒有考慮到這個辦法而在系統完成后再去這些工作則工作量可能會很大,好在jsp規范提供了一種簡單的解決辦法,通過在web.xml中設定全局錯誤處理頁面來對整個項目有效,web.xml中對于不同的http返回結果或異常類型可以有不同的處理方式。
    在xml中配置如下:
    <error-page>
    ???<error-code>500</error-code>
    ???<location>error.jsp</location>
    </error-page>
    <error-page>
    ???<error-code>404</error-code>
    ???<location>notfound.jsp</location>
    </error-page>

    通過以上配置,程序會自動根據錯誤類型轉向不同的錯誤頁面。

    posted @ 2007-06-06 15:59 Yemoo'S Java Blog 閱讀(1759) | 評論 (0)編輯 收藏

    前段時間作了一個簡單的系統,其中涉及到后臺管理,當然也就遇到了權限驗證的問題,由于初次做J2EE項目,所有這些東西懂我來說都是個開始。
    對于權限驗證,如果程序由目錄劃分,如管理員訪問的頁面都放在admin下,這樣我們可以寫一個權限驗證的過濾器,然后配置admin目錄都要經過這個過濾器即可。這樣對于jsp頁面的權限驗證比較容易。但對于action(控制器類)就不好控制了,因為action是沒有目錄概念的,如我們訪問action的地址為:http://xxx/sample/ac1.action,同時如果使用http://xxx/sample/xx/xx/ac1.action同樣可以訪問,這是因為只要在這個項目目錄下,訪問的頁面如果為action則struts就會去查詢這個action名字對應的類,而不管前面的目錄結構。因此我們不能再用過濾器對管理員部分的action進行驗證。經過查看struts2的相關資料發現了攔截器這個有用的東西。通過struts2的配置文件的包管理功能和攔截器可以輕松的對指定的action做管理(攔截),如
    ===================================================
    <package name="user" extends="struts-default">
    ??<!-- 前臺用戶操作部分 -->
    ??<!-- 框架頁,顯示分類 -->
    ??<action name="queryCateForwardUI"
    ???class="com.topsoft.bookmanage.web.action.QueryCateForwardActionUI">
    ???<result>/mainPage.jsp</result>
    ??</action>
    ??? 。。。。。
    </package>
    <!-- 管理員操作部分 -->
    ?<package name="manager" extends="struts-default">
    ??<!-- 攔截器 -->
    ??<interceptors>
    ???<interceptor name="auth" class="com.topsoft.common.LogonInterceptor" />
    ???<interceptor-stack name="authStack">?
    ??????????????? <interceptor-ref name="auth"/>?
    ??????????????? <interceptor-ref name="paramsPrepareParamsStack"/>?
    ??????????? </interceptor-stack>?
    ??</interceptors>
    ??<!-- 默認執行的攔截器 -->
    ??<default-interceptor-ref name="authStack"/>
    ??<!-- 全局Action映射 -->
    ??<global-results>
    ???<result name="login" type="redirect">/managerLoginUI.action</result>
    ??</global-results>
    ??
    ??<!-- 后臺管理首頁面UI -->
    ??<action name="managerIndexUI"
    ???class="com.topsoft.bookmanage.web.action.ManagerIndexActionUI">
    ???<result>/admin/index.jsp</result>
    ??</action>
    ?。。。。。。
    </package>
    =================================================

    通過使用攔截器+過濾器可以完美解決權限驗證的問題。

    posted @ 2007-06-06 15:17 Yemoo'S Java Blog 閱讀(4978) | 評論 (6)編輯 收藏

    struts.action.extension
    ????????? The URL extension to use to determine if the request is meant for a Struts action
    ?????????? 用URL擴展名來確定是否這個請求是被用作Struts action,其實也就是設置 action的后綴,例如login.do的'do'字。

    struts.configuration
    ????????? The org.apache.struts2.config.Configuration implementation class
    ??????????? org.apache.struts2.config.Configuration接口名

    struts.configuration.files
    ????????? A list of configuration files automatically loaded by Struts
    ?????????? struts自動加載的一個配置文件列表

    struts.configuration.xml.reload
    ????????? Whether to reload the XML configuration or not
    ?????????? 是否加載xml配置(true,false)

    struts.continuations.package
    ?????????? The package containing actions that use Rife continuations
    ?????????? 含有actions的完整連續的package名稱

    struts.custom.i18n.resources
    ????????? Location of additional localization properties files to load
    ?????????? 加載附加的國際化屬性文件(不包含.properties后綴)

    struts.custom.properties
    ????????? Location of additional configuration properties files to load
    ?????????? 加載附加的配置文件的位置


    struts.devMode
    ????????? Whether Struts is in development mode or not
    ?????????? 是否為struts開發模式

    struts.dispatcher.parametersWorkaround
    ????????? Whether to use a Servlet request parameter workaround necessary for some versions of WebLogic
    ??????????? (某些版本的weblogic專用)是否使用一個servlet請求參數工作區(PARAMETERSWORKAROUND)

    struts.enable.DynamicMethodInvocation
    ????????? Allows one to disable dynamic method invocation from the URL
    ??????????? 允許動態方法調用

    struts.freemarker.manager.classname
    ????????? The org.apache.struts2.views.freemarker.FreemarkerManager implementation class
    ?????????? org.apache.struts2.views.freemarker.FreemarkerManager接口名

    struts.i18n.encoding
    ????????? The encoding to use for localization messages
    ?????????? 國際化信息內碼

    struts.i18n.reload
    ????????? Whether the localization messages should automatically be reloaded
    ?????????? 是否國際化信息自動加載

    struts.locale
    ????????? The default locale for the Struts application
    ?????????? 默認的國際化地區信息

    struts.mapper.class
    ????????? The org.apache.struts2.dispatcher.mapper.ActionMapper implementation class
    ??????????? org.apache.struts2.dispatcher.mapper.ActionMapper接口

    struts.multipart.maxSize
    ????????? The maximize size of a multipart request (file upload)
    ?????????? multipart請求信息的最大尺寸(文件上傳用)

    struts.multipart.parser
    ????????? The org.apache.struts2.dispatcher.multipart.MultiPartRequest parser implementation for a multipart request (file upload)
    ????????? 專為multipart請求信息使用的org.apache.struts2.dispatcher.multipart.MultiPartRequest解析器接口(文件上傳用)


    struts.multipart.saveDir
    ????????? The directory to use for storing uploaded files
    ?????????? 設置存儲上傳文件的目錄夾

    struts.objectFactory
    ????????? The com.opensymphony.xwork2.ObjectFactory implementation class
    ?????????? com.opensymphony.xwork2.ObjectFactory接口(spring)

    struts.objectFactory.spring.autoWire
    ????????? Whether Spring should autoWire or not
    ?????????? 是否自動綁定Spring

    struts.objectFactory.spring.useClassCache
    ????????? Whether Spring should use its class cache or not
    ?????????? 是否spring應該使用自身的cache

    struts.objectTypeDeterminer
    ????????? The com.opensymphony.xwork2.util.ObjectTypeDeterminer implementation class
    ??????????? com.opensymphony.xwork2.util.ObjectTypeDeterminer接口

    struts.serve.static.browserCache
    ????????? If static content served by the Struts filter should set browser caching header properties or not
    ?????????? 是否struts過濾器中提供的靜態內容應該被瀏覽器緩存在頭部屬性中

    struts.serve.static
    ????????? Whether the Struts filter should serve static content or not
    ?????????? 是否struts過濾器應該提供靜態內容

    struts.tag.altSyntax
    ????????? Whether to use the alterative syntax for the tags or not
    ?????????? 是否可以用替代的語法替代tags

    struts.ui.templateDir
    ????????? The directory containing UI templates
    ?????????? UI templates的目錄夾

    struts.ui.theme
    ????????? The default UI template theme
    ?????????? 默認的UI template主題

    struts.url.http.port
    ????????? The HTTP port used by Struts URLs
    ?????????? 設置http端口

    struts.url.https.port
    ????????? The HTTPS port used by Struts URLs
    ?????????? 設置https端口

    struts.url.includeParams
    ????????? The default includeParams method to generate Struts URLs
    ????????? 在url中產生 默認的includeParams


    struts.velocity.configfile
    ????????? The Velocity configuration file path
    ?????????? velocity配置文件路徑

    struts.velocity.contexts
    ????????? List of Velocity context names
    ?????????? velocity的context列表


    struts.velocity.manager.classname
    ????????? org.apache.struts2.views.velocity.VelocityManager implementation class
    ?????????? org.apache.struts2.views.velocity.VelocityManager接口名

    struts.velocity.toolboxlocation
    ????????? The location of the Velocity toolbox
    ?????????? velocity工具盒的位置
    struts.xslt.nocache
    ????????? Whether or not XSLT templates should not be cached
    ?????????? 是否XSLT模版應該被緩存

    posted @ 2007-05-20 19:05 Yemoo'S Java Blog 閱讀(543) | 評論 (0)編輯 收藏

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "

    <beans>

    ??建立一個數據源
    ?<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    ? <property name="driverClassName">
    ?? <value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
    ? </property>
    ? <property name="url">
    ?? <value>jdbc:microsoft:sqlserver://192.168.0.6:1433</value>
    ? </property>
    ? <property name="username">
    ?? <value>sa</value>
    ? </property>
    ? <property name="password">
    ?? <value></value>
    ? </property>
    ?</bean>

    ? 建立會話工廠類,這個類使用spring專門為hibernate3提供LocalSessionFactoryBean
    ?
    ?<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    ? <property name="dataSource">
    ?? <ref local="dataSource" />? --引用上面的數據源
    ? </property>
    ? <property name="mappingResources">? --調入映射文檔
    ?? <list>
    ??? <value>com/yourcompany/User.hbm.xml</value>?
    ?? </list>
    ? </property>
    ? <property name="hibernateProperties">? --相關設置
    ?? <props>
    ??? <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
    ??? <prop key="hibernate.show_sql">true</prop>
    ?? </props>
    ? </property>
    ?</bean>
    ??

    ??? 定義事務管理器,這個也是 spring專門為hibernate3提供的HibernateTransactionManager 事務管理器
    ?<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    ? <property name="sessionFactory">
    ?? <ref local="sessionFactory" />?? --引用會話工廠類
    ? </property>
    ?</bean>

    ?定義實體DAO
    ?<bean id="userDAO" class="com.yourcompany.UserDAOImp">
    ? <property name="sessionFactory">
    ?? <ref local="sessionFactory" />--引用會話工廠類
    ? </property>
    ?</bean>
    ?

    ?為上面的實體DAO定義一個代理(proxy)類,這是spring為解決事務問題而提供TransactionProxyFactoryBean動態事務代理類
    ?<bean id="userDAOProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    ? <property name="transactionManager">
    ?? <ref bean="transactionManager" />? --指定事務管理器(需要是spring專用的)
    ? </property>
    ? <property name="target"> --目標實體DAO類
    ?? <ref local="userDAO" />
    ? </property>
    ? <property name="transactionAttributes"> --定義要使用事務的方法
    ?? <props>
    ??? <prop key="insert*">PROPAGATION_REQUIRED</prop>? --所有insert開頭的方法都使用事務,出錯要回滾
    ??? <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop> --所有get開頭的方法都使用只讀事務
    ??? <prop key="is*">PROPAGATION_REQUIRED,readOnly</prop>--所有ist開頭的方法都使用只讀事務
    ?? </props>
    ? </property>
    ?</bean>

    ??為 path="/login"?的struts action 定義實際的action類,該action?已經進行?type="org.springframework.web.struts.DelegatingActionProxy"設置
    ? <bean name="/login" class="com.yourcompany.struts.action.LoginAction" singleton="false">
    ??? <property name="userDAO">
    ??? <ref bean="userDAOProxy" />? --注意,這里指定的userDAO是上面定義的代理類
    ? </property>
    ?</bean>
    </beans>?

    posted on 2006-12-05 15:40 kelven 閱讀(1

    posted @ 2007-05-15 08:21 Yemoo'S Java Blog 閱讀(417) | 評論 (0)編輯 收藏

    今天把jdk從1.6.0卸載后又安裝了1.5.04,然后發現netbeans無法啟動,提示“Cannot find java.exe...”,在網上看到很多人說要修改環境變量,但是偶的環境變量在安裝完jdk后就配置好了,沒有問題。
    于是又費了老半天的力氣,終于解決了,辦法如下:
    1,啟動jdk時 --jdkhome參數指出jdk路徑
    2,修改netbean目錄下的/etc目錄下的netbeans.conf中的jdkhome的值為當前jdk路徑

    使用上面方法中之一即可!

    posted @ 2007-03-11 16:54 Yemoo'S Java Blog 閱讀(4441) | 評論 (0)編輯 收藏

    主站蜘蛛池模板: 亚洲五月综合网色九月色| 亚洲尹人九九大色香蕉网站| 亚洲av无码一区二区三区天堂| 成人奭片免费观看| 亚洲国产美女精品久久久| 又爽又黄无遮挡高清免费视频| 免费人成网站永久| 久久亚洲精品无码| 手机看片久久国产免费| 182tv免费视频在线观看| 亚洲高清美女一区二区三区| caoporm碰最新免费公开视频| 日本视频免费在线| 人与动性xxxxx免费| 亚洲狠狠综合久久| 国产yw855.c免费视频| 久久久久久毛片免费看| 亚洲毛片在线免费观看| 亚洲Av无码国产情品久久| 99在线精品视频观看免费| jizz免费在线影视观看网站| 亚洲人成电影在线观看青青| 久久亚洲国产精品五月天婷| 最新黄色免费网站| eeuss草民免费| 久久久久亚洲国产AV麻豆 | 亚洲精品无码乱码成人| 青青在线久青草免费观看| 国产精品一区二区三区免费 | 国产免费人视频在线观看免费| aa在线免费观看| 黄色毛片免费网站| 亚洲av无码有乱码在线观看| 国产亚洲一区二区手机在线观看| 日韩在线天堂免费观看| 亚洲精品视频在线免费| 免费污视频在线观看| 国产性生大片免费观看性| 久久亚洲欧美国产精品| 亚洲老熟女五十路老熟女bbw| 亚洲国产精品久久网午夜|