`
fly1206
  • 浏览: 57110 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

日系框架之seasar2(S2Struts)---(下)

阅读更多

 validator-rules.xml

<!DOCTYPEform-validationPUBLIC
     "-//ApacheSoftwareFoundation//DTDCommonsValidatorRulesConfiguration1.1.3//EN"
     "http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
<!--
 ThisfilecontainsthedefaultStrutsValidatorpluggablevalidator
 definitions. Itshouldbeplacedsomewhereunder/WEB-INFand
 referencedinthestruts-config.xmlundertheplug-inelement
 fortheValidatorPlugIn.
   <plug-inclassName="org.apache.struts.validator.ValidatorPlugIn">
    <set-propertyproperty="pathnames"value="/WEB-INF/validator-rules.xml,
                         /WEB-INF/validation.xml"/>
   </plug-in>
 Thesearethedefaulterrormessagesassociatedwith
 eachvalidatordefinedinthisfile. Theyshouldbe
 addedtoyourprojectsApplicationResources.properties
 fileoryoucanassociatenewonesbymodifyingthe
 pluggablevalidatorsmsgattributesinthisfile.
 #StrutsValidatorErrorMessages
 errors.required={0}isrequired.
 errors.minlength={0}cannotbelessthan{1}characters.
 errors.maxlength={0}cannotbegreaterthan{1}characters.
 errors.invalid={0}isinvalid.
 errors.byte={0}mustbeabyte.
 errors.short={0}mustbeashort.
 errors.integer={0}mustbeaninteger.
 errors.long={0}mustbealong.
 errors.float={0}mustbeafloat.
 errors.double={0}mustbeadouble.
 errors.date={0}isnotadate.
 errors.range={0}isnotintherange{1}through{2}.
 errors.creditcard={0}isaninvalidcreditcardnumber.
 errors.email={0}isaninvalide-mailaddress.
 errors.url={0}isaninvalidurl(webaddress).
 errors.minbytelength={0}cannotbelessthan{1}bytes.
 errors.maxbytelength={0}cannotbegreaterthan{1}bytes.
 Note:StartinginStruts1.2.0thedefaultjavascriptdefinitionshave
    beenconsolidatedtocommons-validator.Thedefaultcanbeoverridden
    bysupplyinga<javascript>elementwithaCDATAsection,justas
    instruts1.1.
-->
<form-validation>
 <global>
   <validatorname="required"
      classname="org.apache.struts.validator.FieldChecks"
       method="validateRequired"
    methodParams="java.lang.Object,
           org.apache.commons.validator.ValidatorAction,
           org.apache.commons.validator.Field,
           org.apache.struts.action.ActionMessages,
           org.apache.commons.validator.Validator,
           javax.servlet.http.HttpServletRequest"
         msg="errors.required"/>
   <validatorname="requiredif"
        classname="org.apache.struts.validator.FieldChecks"
        method="validateRequiredIf"
        methodParams="java.lang.Object,
               org.apache.commons.validator.ValidatorAction,
               org.apache.commons.validator.Field,
               org.apache.struts.action.ActionMessages,
               org.apache.commons.validator.Validator,
               javax.servlet.http.HttpServletRequest"
        msg="errors.required"/>
   <validatorname="validwhen"
     msg="errors.required"
        classname="org.apache.struts.validator.validwhen.ValidWhen"
        method="validateValidWhen"
        methodParams="java.lang.Object,
           org.apache.commons.validator.ValidatorAction,
           org.apache.commons.validator.Field,
           org.apache.struts.action.ActionMessages,
           org.apache.commons.validator.Validator,
           javax.servlet.http.HttpServletRequest"/>
   <validatorname="minlength"
      classname="org.apache.struts.validator.FieldChecks"
       method="validateMinLength"
    methodParams="java.lang.Object,
           org.apache.commons.validator.ValidatorAction,
           org.apache.commons.validator.Field,
           org.apache.struts.action.ActionMessages,
           org.apache.commons.validator.Validator,
           javax.servlet.http.HttpServletRequest"
       depends=""
         msg="errors.minlength"
     jsFunction="org.apache.commons.validator.javascript.validateMinLength"/>
   <validatorname="maxlength"
      classname="org.apache.struts.validator.FieldChecks"
       method="validateMaxLength"
    methodParams="java.lang.Object,
           org.apache.commons.validator.ValidatorAction,
           org.apache.commons.validator.Field,
           org.apache.struts.action.ActionMessages,
           org.apache.commons.validator.Validator,
           javax.servlet.http.HttpServletRequest"
       depends=""
         msg="errors.maxlength"
     jsFunction="org.apache.commons.validator.javascript.validateMaxLength"/>
   <validatorname="mask"
      classname="org.apache.struts.validator.FieldChecks"
       method="validateMask"
    methodParams="java.lang.Object,
           org.apache.commons.validator.ValidatorAction,
           org.apache.commons.validator.Field,
           org.apache.struts.action.ActionMessages,
           org.apache.commons.validator.Validator,
           javax.servlet.http.HttpServletRequest"
       depends=""
         msg="errors.invalid"/>
   <validatorname="byte"
      classname="org.apache.struts.validator.FieldChecks"
       method="validateByte"
    methodParams="java.lang.Object,
           org.apache.commons.validator.ValidatorAction,
           org.apache.commons.validator.Field,
           org.apache.struts.action.ActionMessages,
           org.apache.commons.validator.Validator,
           javax.servlet.http.HttpServletRequest"
       depends=""
         msg="errors.byte"
   jsFunctionName="ByteValidations"/>
   <validatorname="short"
      classname="org.apache.struts.validator.FieldChecks"
       method="validateShort"
    methodParams="java.lang.Object,
           org.apache.commons.validator.ValidatorAction,
           org.apache.commons.validator.Field,
           org.apache.struts.action.ActionMessages,
           org.apache.commons.validator.Validator,
           javax.servlet.http.HttpServletRequest"
       depends=""
         msg="errors.short"
   jsFunctionName="ShortValidations"/>
   <validatorname="integer"
      classname="org.apache.struts.validator.FieldChecks"
       method="validateInteger"
    methodParams="java.lang.Object,
           org.apache.commons.validator.ValidatorAction,
           org.apache.commons.validator.Field,
           org.apache.struts.action.ActionMessages,
           org.apache.commons.validator.Validator,
           javax.servlet.http.HttpServletRequest"
       depends=""
         msg="errors.integer"
   jsFunctionName="IntegerValidations"/>
   <validatorname="long"
      classname="org.apache.struts.validator.FieldChecks"
       method="validateLong"
    methodParams="java.lang.Object,
           org.apache.commons.validator.ValidatorAction,
           org.apache.commons.validator.Field,
           org.apache.struts.action.ActionMessages,
           org.apache.commons.validator.Validator,
           javax.servlet.http.HttpServletRequest"
       depends=""
         msg="errors.long"/>
   <validatorname="float"
      classname="org.apache.struts.validator.FieldChecks"
       method="validateFloat"
    methodParams="java.lang.Object,
           org.apache.commons.validator.ValidatorAction,
           org.apache.commons.validator.Field,
           org.apache.struts.action.ActionMessages,
           org.apache.commons.validator.Validator,
           javax.servlet.http.HttpServletRequest"
       depends=""
         msg="errors.float"
   jsFunctionName="FloatValidations"/>
   <validatorname="double"
      classname="org.apache.struts.validator.FieldChecks"
       method="validateDouble"
    methodParams="java.lang.Object,
           org.apache.commons.validator.ValidatorAction,
           org.apache.commons.validator.Field,
           org.apache.struts.action.ActionMessages,
           org.apache.commons.validator.Validator,
           javax.servlet.http.HttpServletRequest"
       depends=""
         msg="errors.double"/>
   <validatorname="date"
      classname="org.apache.struts.validator.FieldChecks"
       method="validateDate"
    methodParams="java.lang.Object,
           org.apache.commons.validator.ValidatorAction,
           org.apache.commons.validator.Field,
           org.apache.struts.action.ActionMessages,
           org.apache.commons.validator.Validator,
           javax.servlet.http.HttpServletRequest"
       depends=""
         msg="errors.date"
   jsFunctionName="DateValidations"/>
   <validatorname="intRange"
      classname="org.apache.struts.validator.FieldChecks"
       method="validateIntRange"
    methodParams="java.lang.Object,
           org.apache.commons.validator.ValidatorAction,
           org.apache.commons.validator.Field,
           org.apache.struts.action.ActionMessages,
           org.apache.commons.validator.Validator,
           javax.servlet.http.HttpServletRequest"
       depends="integer"
         msg="errors.range"/>
   <validatorname="floatRange"
      classname="org.apache.struts.validator.FieldChecks"
       method="validateFloatRange"
    methodParams="java.lang.Object,
           org.apache.commons.validator.ValidatorAction,
           org.apache.commons.validator.Field,
           org.apache.struts.action.ActionMessages,
           org.apache.commons.validator.Validator,
           javax.servlet.http.HttpServletRequest"
       depends="float"
         msg="errors.range"/>
   <validatorname="doubleRange"
      classname="org.apache.struts.validator.FieldChecks"
       method="validateDoubleRange"
    methodParams="java.lang.Object,
           org.apache.commons.validator.ValidatorAction,
           org.apache.commons.validator.Field,
           org.apache.struts.action.ActionMessages,
           org.apache.commons.validator.Validator,
           javax.servlet.http.HttpServletRequest"
       depends="double"
         msg="errors.range"/>
   <validatorname="creditCard"
      classname="org.apache.struts.validator.FieldChecks"
       method="validateCreditCard"
    methodParams="java.lang.Object,
           org.apache.commons.validator.ValidatorAction,
           org.apache.commons.validator.Field,
           org.apache.struts.action.ActionMessages,
           org.apache.commons.validator.Validator,
           javax.servlet.http.HttpServletRequest"
       depends=""
         msg="errors.creditcard"/>
   <validatorname="email"
      classname="org.apache.struts.validator.FieldChecks"
       method="validateEmail"
    methodParams="java.lang.Object,
           org.apache.commons.validator.ValidatorAction,
           org.apache.commons.validator.Field,
           org.apache.struts.action.ActionMessages,
           org.apache.commons.validator.Validator,
           javax.servlet.http.HttpServletRequest"
       depends=""
         msg="errors.email"/>
   <validatorname="url"
      classname="org.apache.struts.validator.FieldChecks"
       method="validateUrl"
    methodParams="java.lang.Object,
           org.apache.commons.validator.ValidatorAction,
           org.apache.commons.validator.Field,
           org.apache.struts.action.ActionMessages,
           org.apache.commons.validator.Validator,
           javax.servlet.http.HttpServletRequest"
       depends=""
         msg="errors.url"/>
   <validatorname="minbytelength"
      classname="org.seasar.struts.validator.FieldChecks"
       method="validateMinByteLength"
    methodParams="java.lang.Object,
           org.apache.commons.validator.ValidatorAction,
           org.apache.commons.validator.Field,
           org.apache.struts.action.ActionMessages,
           org.apache.commons.validator.Validator,
           javax.servlet.http.HttpServletRequest"
       depends=""
         msg="errors.minbytelength"/>
   <validatorname="maxbytelength"
      classname="org.seasar.struts.validator.FieldChecks"
       method="validateMaxByteLength"
    methodParams="java.lang.Object,
           org.apache.commons.validator.ValidatorAction,
           org.apache.commons.validator.Field,
           org.apache.struts.action.ActionMessages,
           org.apache.commons.validator.Validator,
           javax.servlet.http.HttpServletRequest"
       depends=""
         msg="errors.maxbytelength"/>
  <!--
   ThissimplyallowsstrutstoincludethevalidateUtilitiesintoapage,itshould
   notbeusedasavalidationrule.
  -->
  <validatorname="includeJavaScriptUtilities"
      classname=""
       method=""
    methodParams=""
       depends=""
         msg=""
     jsFunction="org.apache.commons.validator.javascript.validateUtilities"/>
 </global>
</form-validation>

 

 

web.xml

<?xmlversion="1.0"encoding="ISO-8859-1"?>
<!DOCTYPEweb-app
  PUBLIC"-//SunMicrosystems,Inc.//DTDWebApplication2.3//EN"
  "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
 <display-name>StrutsApplication</display-name>
 <filter>
  <filter-name>s2filter</filter-name>
  <filter-class>org.seasar.framework.container.filter.S2ContainerFilter</filter-class>
 </filter>
 <filter>
  <filter-name>s2strutsfilter</filter-name>
  <filter-class>org.seasar.struts.filter.S2StrutsFilter</filter-class>
 </filter>
 <filter>
  <filter-name>encodingfilter</filter-name>
  <filter-class>org.seasar.extension.filter.EncodingFilter</filter-class>
  <init-param>
   <param-name>encoding</param-name>
   <param-value>Windows-31j</param-value>
  </init-param>
 </filter>
 <filter-mapping>
  <filter-name>s2filter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>
 <filter-mapping>
  <filter-name>s2strutsfilter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>
 <filter-mapping>
  <filter-name>encodingfilter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>
 <servlet>
  <servlet-name>s2container</servlet-name>
  <servlet-class>org.seasar.framework.container.servlet.S2ContainerServlet</servlet-class>
  <load-on-startup>1</load-on-startup>
 </servlet>
 <!--StandardActionServletConfiguration(withdebugging)-->
 <servlet>
  <servlet-name>action</servlet-name>
  <servlet-class>org.seasar.struts.servlet.S2ActionServlet</servlet-class>
  <init-param>
   <param-name>config</param-name>
   <param-value>/WEB-INF/struts-config.xml</param-value>
  </init-param>
  <init-param>
   <param-name>debug</param-name>
   <param-value>2</param-value>
  </init-param>
  <init-param>
   <param-name>detail</param-name>
   <param-value>2</param-value>
  </init-param>
  <load-on-startup>2</load-on-startup>
 </servlet>
 <servlet>
  <servlet-name>MayaaServlet</servlet-name>
  <servlet-class>org.seasar.mayaa.impl.MayaaServlet</servlet-class>
  <load-on-startup>3</load-on-startup>
 </servlet>
 <servlet-mapping>
  <servlet-name>s2container</servlet-name>
  <url-pattern>/s2container</url-pattern>
 </servlet-mapping>
 <!--StandardActionServletMapping-->
 <servlet-mapping>
  <servlet-name>action</servlet-name>
  <url-pattern>*.do</url-pattern>
 </servlet-mapping>
 <servlet-mapping>
  <servlet-name>MayaaServlet</servlet-name>
  <url-pattern>*.html</url-pattern>
 </servlet-mapping>
 <!--TheUsualWelcomeFileList-->
 <welcome-file-list>
  <welcome-file>index.html</welcome-file>
  <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>
</web-app>

 

 

 debug.js

/*settrue/false*/
vardebug=true;
if(debug){
  load("dump.js");
}

  default.mayaa

<?xmlversion="1.0"encoding="UTF-8"?>
<m:mayaaxmlns:m="http://mayaa.seasar.org">
  <m:beforeRender><![CDATA[
    varcontextPath=request.getContextPath();
    varprintln=function(value){
      if(value!=null){
        java.lang.System.out.println(value);
      }else{
        java.lang.System.out.println(""+value);
      }
    };
    load("debug.js");
  ]]></m:beforeRender>
</m:mayaa>

  dump.js

functionprintAttribute(req){
  varnames=req.getAttributeNames();
  while(names.hasMoreElements()){
    varname=names.nextElement();
    print("att:"+name+"="+req.getAttribute(name));
  }
}
functionprintParameter(req){
  varnames=req.getParameterNames();
  while(names.hasMoreElements()){
    varname=names.nextElement();
    print("prm:"+name+"="+req.getParameter(name));
  }
}
functionprintSession(session){
  varnames=session.getAttributeNames();
  while(names.hasMoreElements()){
    varname=names.nextElement();
    print("ses:"+name+"="+session.getAttribute(name));
  }
}
functionprint(value){
  java.lang.System.out.println(""+value);
}
varreq=request.getUnderlyingContext();
print("------req-path:"+request.getRequestedPath());
printParameter(req);
printAttribute(req);
printSession(req.getSession());

 

  index.html

<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN">
<html>
<head>
 <linkhref="../../css/global.css"rel="stylesheet"type="text/css"></link>
 <scripttype="text/javascript"src="../../js/execute.js"></script>
 <titleid="pageTitle">
  S2StrutsSampleCalculateApplicationDemo
 </title> 
</head>
<body>
<divid="appBody">
</div>
</body>
</html>

  index.mayaa

<?xmlversion="1.0"encoding="Shift_JIS"?>
<m:mayaaxmlns:m="http://mayaa.seasar.org" 
    xmlns:bean="http://struts.apache.org/tags-bean"
    m:noCache="true"
    m:extends="/pages/layout/layout.html">
  <m:doRenderid="pageTitle"name="title">
    <bean:messagekey="sample.title"/>
  </m:doRender>
  <m:doRenderid="appBody"name="content"/>
</m:mayaa>

分享到:
评论

相关推荐

    一个日系seasar框架Demo:S2Containor+S2Dao+SAStruts+mayaa

    SAStruts是Seasar对经典的Struts框架的扩展,它提供了更强大的MVC(Model-View-Controller)架构支持。SAStruts将控制逻辑与视图逻辑分离,使得开发者可以独立地修改模型、视图和控制器部分。它还集成了S2Container...

    seasar框架S2Dao使用指南

    S2Dao是Seasar2框架的一个重要组成部分,作为一个轻量级的持久化解决方案,它的主要特点是简化了Object-Relational Mapping(O/R映射)的过程,无需繁琐的XML配置。S2Dao的核心优势在于: 1. **无需XML配置**:与...

    小日本的开源框架 Seasar2

    使用Seasar2的基本功能(如S2Container和S2AOP)时,需要在CLASSPATH下包含一系列特定的JAR文件,包括aopalliance、commons-logging、javassist、ognl和s2-framework等。 如果要利用Seasar2的扩展功能,如S2JTA、S2...

    seasar2

    这份幻灯片的内容主要围绕S2Struts展开,S2Struts是Seasar2框架的一个组件,它结合了Seasar2的强大功能和Struts的灵活性。 ### S2Struts概述 S2Struts是一个基于Seasar2的Web应用开发框架,它融合了Struts的一些...

    sa_framework,s2-tiger,s2-extension2.4 日文的api

    标题 "sa_framework, s2-tiger, s2-extension2.4 日文的API" 暗示了我们正在探讨的是Seasar2框架的一个特定版本,包括s2-tiger和s2-extension2.4的组件,这些组件都有日文的API文档。Seasar2是一个Java企业级应用...

    S2Tiger-2.3.23.zip

    Seasar2是一个开源的Java应用框架,其核心组件之一就是S2Tiger,你提到的"S2Tiger-2.3.23.zip"应该是Seasar2的一个版本更新,主要聚焦于依赖注入(DI)和面向切面编程(AOP)。在深入探讨这些知识点之前,我们先了解...

    seasar2中文文档

    在这个过程中,我们将学习Seasar2中的核心组件之一——`S2Container`。 ##### 登场人物 - **问候语类** (`Greeting`):接口形式,用于定义问候语的行为。 - **问候客户端类** (`GreetingClient`):接口形式,用于...

    s2-dao-1.0.49.zip

    1. "s2dao":这个目录很可能包含了Seasar2 DAO框架的核心库,包括必要的Java类和接口,使得开发者可以方便地进行数据库操作。 2. "s2dao-tiger":可能是一个针对特定JVM版本或者特定数据库优化的模块,例如“Tiger”...

    Seasar2其实就是类似于Spring的一个开源框架

    - **无配置文件**:与传统的Java框架不同,Seasar2允许开发者在不编写任何配置文件的情况下进行开发工作,这大大简化了开发流程。 - **动态热部署**(Hot Deploy):Seasar2支持应用程序的即时更改检测,这意味着当...

    s2-dao-1.0.50.zip

    S2-DAO是Seasar框架中的一个重要部分,全称为"Seasar2 Data Access Object",它提供了数据访问层的抽象,使得开发者能够更方便地进行数据库操作,而无需直接编写SQL语句。这个"seasar框架的讲解s2-dao"压缩包,显然...

    S2Flex2-1.1.0

    《S2Flex2-1.1.0:Seasar2框架与Flex交互的深度解析》 在现代Web应用开发中,交互性和用户体验是至关重要的因素。S2Flex2-1.1.0是一个专为Flash播放器设计的软件库,它使得开发者能够利用Adobe Flex这一强大的...

    Seasar2最新版

    Seasar2框架包含多个组件,如S2Container(容器)、S2DAO(数据访问对象)、S2Action(动作)以及S2Remoting(远程调用)等。这些组件相互协作,构建出一个强大的企业级应用开发环境。 1. S2Container:作为Seasar2...

    seasar2构建工程

    3. **S2Bootstrap**:Seasar2启动的核心是`S2Bootstrap`类,它负责初始化框架并管理应用的生命周期。在项目中,通常需要编写一个主类,通过调用`S2Bootstrap.launch`方法来启动应用。 4. **S2Container**:Seasar2...

    seasar教程,java开发框架之一

    seasar教程,最流行的java开发框架之一,再过几年可能成为主流. struts与Spring与Hibernate的简化版本,国外很多大公司己经用了几年了,NEC,LG的软件开发都是用这个的。兄弟们快学吧

    seasar2 官方例子代码

    3. **S2JUnit**:这是Seasar2提供的单元测试框架,扩展了标准的JUnit,提供了数据库回滚、事务管理等功能,使得在测试环境中更加方便地进行数据库操作。 4. **S2Aop**:面向切面编程模块,允许开发者定义切面,从而...

    seasar2.PPT

    Seasar2是一个开源的Java框架,主要功能包括依赖注入(Dependency Injection,简称DI)和面向切面编程(Aspect Oriented Programming,简称AOP)。这个框架的设计目标是提高开发效率,通过将组件(Plain Old Java ...

    Seasar2的英文介绍

    然而,尽管Seasar2在当时是流行的框架之一,随着Spring框架的崛起,Seasar2的使用逐渐减少。不过,对于学习和理解组件化、容器化以及面向切面编程等概念,Seasar2仍是一个有价值的参考和学习资源。

    seasar2 samples

    然而,你提到的是"seasar2 samples",但结合描述,似乎这里指的是.NET环境下的一个类似实现,可能是基于C#的一个库,命名为s2dao.net。这是一个用于学习数据库操作的示例项目。 1. **S2DAO.NET**:假设s2dao.net是...

Global site tag (gtag.js) - Google Analytics