CenturyMagus的专栏

www.err123.cn ,收集各类编程错误的解决方案,欢迎大家访问

用户操作
[即时聊天] [发私信] [加为好友]
magusID:CenturyMagus
62795次访问,排名1686好友2人,关注者3
CenturyMagus的文章
原创 42 篇
翻译 1 篇
转载 40 篇
评论 23 篇
CenturyMagus的公告

ah011一起在友播听歌吧!
最近评论
zhengyuanting:通过URL传中文,如果不是post的话,是会乱码的
qq386232894:好文章!!!!
fz04003:谢谢啊,我终于搞懂这个东西了。
虽然我用的是JQuery,但是终于搞懂Struts这块是怎么回事了,谢谢!
小脚:终于全部搞懂了!!!谢谢老大~
小小鸟:好文章.比其他好多地方都讲的清楚透彻.赞一个.
文章分类
收藏
    相册
    编程网站
    Apache
    IBM DeveloperWorks
    onjava
    W3C
    编程错误解决方案收集
    计算机词汇在线词典
    存档
    订阅我的博客
    XML聚合  FeedSky
    订阅到鲜果
    订阅到Google
    订阅到抓虾
    订阅到BlogLines
    订阅到Yahoo
    订阅到GouGou
    订阅到飞鸽
    订阅到Rojo
    订阅到newsgator
    订阅到netvibes

    转载 Ant 条件判断 condition收藏

    新一篇: JSP页面乱码分析及解决 | 旧一篇: 简明Ant学习笔记

     1、istrue isfalse:断言 真 假


    <project name="testCondition">
        <target name="test">
            <condition property="scondition">
                <istrue value="true"/>                    
            </condition>
            <antcall target="isTrue"></antcall>
            <antcall target="isFalse"></antcall>        
        </target>
        <target name="isTrue" if="scondition">
            <echo>is ture</echo>
        </target>
        <target name="isFalse" unless="scondition">
            <echo>is false</echo>
        </target>
    </project>
        2、逻辑运算
        2.1、not 逻辑非 

    <project name="testCondition">
        <target name="test">
            <condition property="scondition">
                <not>
                    <istrue value="true"/>                    
                </not>
            </condition>
            <antcall target="isTrue"></antcall>
            <antcall target="isFalse"></antcall>        
        </target>
        <target name="isTrue" if="scondition">
            <echo>is ture</echo>
        </target>
        <target name="isFalse" unless="scondition">
            <echo>is false</echo>
        </target>
    </project>
        2.2、and 逻辑与

    <project name="testCondition">
        <target name="test">
            <condition property="scondition">
                <and>
                    <istrue value="true"/>
                    <istrue value="false"/>                    
                </and>
            </condition>
            <antcall target="isTrue"></antcall>
            <antcall target="isFalse"></antcall>        
        </target>
        <target name="isTrue" if="scondition">
            <echo>is ture</echo>
        </target>
        <target name="isFalse" unless="scondition">
            <echo>is false</echo>
        </target>
    </project>
        2.3、or 逻辑或 xor异或 (语法上与and类似)

        3、available 是否可用


    <project name="testCondition">
        <path id="all.test.classes">         
             <pathelement location="bin"/>
        </path>
        <target name="test">
            <condition property="scondition">
                <!--在指定的classpath路径下是否存在资源 TestTest.class-->
                <available resource="TestTest.class">
                    <classpath refid="all.test.classes" />        
                </available>
            </condition>
            <antcall target="isTrue"></antcall>
            <antcall target="isFalse"></antcall>        
        </target>
        <target name="isTrue" if="scondition">
            <echo>is ture</echo>
        </target>
        <target name="isFalse" unless="scondition">
            <echo>is false</echo>
        </target>
    </project>
        4、isset 指定属性是否存在

    <project name="testCondition">
        <!--属性也可以通过ant参数-D来设置-->
        <property name="name" value="this is name"/>    
        <target name="test">
            <condition property="scondition">
                <!--如果属性name不存在则返回false-->
                <isset property="name"/>
            </condition>
            <antcall target="isTrue"></antcall>
            <antcall target="isFalse"></antcall>        
        </target>
        <target name="isTrue" if="scondition">
            <echo>is ture</echo>
        </target>
        <target name="isFalse" unless="scondition">
            <echo>is false</echo>
        </target>
    </project>
        5、equals 是否相等
    <project name="testCondition">
        <!--属性也可以通过ant参数-D来设置-->
        <property name="name" value="this is name"/>    
        <target name="test">
            <condition property="scondition">
                <!--如果arg1的值与arg2的值相等返回true,否则为false-->
                <equals arg1="${name}" arg2="this is name"/>
            </condition>
            <antcall target="isTrue"></antcall>
            <antcall target="isFalse"></antcall>        
        </target>
        <target name="isTrue" if="scondition">
            <echo>is ture</echo>
        </target>
        <target name="isFalse" unless="scondition">
            <echo>is false</echo>
        </target>
    </project> 
       
        6、filesmatch 比较文件
    <project name="testCondition">        
        <target name="test">
            <condition property="scondition">
                <!--如果file1所代表的文件与file2所代表的文件相等返回true,否则为false-->
                <filesmatch file1="testfile1.txt" file2="testfile2.txt"/>
            </condition>
            <antcall target="isTrue"></antcall>
            <antcall target="isFalse"></antcall>        
        </target>
        <target name="isTrue" if="scondition">
            <echo>is ture</echo>
        </target>
        <target name="isFalse" unless="scondition">
            <echo>is false</echo>
        </target>
    </project>

    发表于 @ 2008年07月23日 11:53:00|评论(loading...)|编辑|收藏

    新一篇: JSP页面乱码分析及解决 | 旧一篇: 简明Ant学习笔记

    评论:没有评论。

    发表评论  


    登录
    Csdn Blog version 3.1a
    Copyright © CenturyMagus