Java Home

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

          日歷

          <2007年5月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          公告

          未經本人特別聲明,本站所有文章均屬作者本人原創,請轉載時注明來源,謝謝合作!

          JavaBlog

          搜索

          •  

          積分與排名

          • 積分 - 48952
          • 排名 - 1005

          最新評論

          2007年5月20日

          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 閱讀(502) | 評論 (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 閱讀(1761) | 評論 (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 閱讀(4982) | 評論 (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 閱讀(549) | 評論 (0)編輯 收藏

          主站蜘蛛池模板: 湟源县| 茂名市| 简阳市| 三河市| 广元市| 临澧县| 奇台县| 霍邱县| 德保县| 伊宁县| 黄平县| 和静县| 张家口市| 正镶白旗| 育儿| 龙陵县| 河北省| 万源市| 望谟县| 鹤峰县| 长乐市| 通化市| 石柱| 贵州省| 敖汉旗| 酒泉市| 闽侯县| 石嘴山市| 泊头市| 南部县| 昌江| 辽阳县| 蒙山县| 晋州市| 安新县| 寻乌县| 郑州市| 襄城县| 绥江县| 中江县| 嘉禾县|