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

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

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

    asdtiang的博客 感謝blogjava提供的博客交流平臺(tái)
    grails 命令:
    shell
    console   //啟動(dòng)一個(gè)類似groovy 的console,console里可以訪問(wèn)domain.service等。



    controller里的已有變量(自己不常用的記下,其它的查看文檔,例如request,reponse)

    actionName

    Purpose

    Returns the name of the currently executing action.


    controllerName

    Purpose

    Returns the name of the currently executing controller.

    defaultAction

    Purpose

    Allows you to explicitly specify the default action that should be executed if no action is specified in the URI.

    Examples

    class BookController {
    static defaultAction = "list"
    def list = {
    [books:Book.list()]
    }
    }

    grailsApplication

    Purpose

    An instance of the org.codehaus.groovy.grails.commons.GrailsApplication class.

    Examples

    class BookController {
    def list = {
    def bookClass = grailsApplication.classLoader.loadClass("Book")
    [book:bookClass.newInstance()]
    }
    }

    Description

    The GrailsApplication class provides information about the conventions within Grails and access to metadata, config and the ClassLoader






    servletContext

    Purpose

    The servletContext object is an instance of the Servlet API's ServletContext class.

    Examples

    class BookController {
    def doSomething = {
    def input
    try {
    input = servletContext.getResourceAsStream("/WEB-INF/myscript.groovy")
    def result = new GroovyShell().evaluate(input.text)
    render result
    }
    finally {
    input.close()
    }
    

    } }

    Description

    The Servlet API's ServletContext is useful for, amongst other things, storing global application attributes, reading local server resources and establishing information about the servlet container.







    withForm //防止重復(fù)提交表單

    Purpose

    Used to handle duplicate form submissions.

    Examples

    withForm {
    // good request
    }.invalidToken {
    // bad request
    }

    Description

    The withForm method requires the use of the useToken attribute in a form

    <g:form useToken="true" ...>

    Then in your controller code you can use the withForm method to handle valid and invalid requests:

    withForm {
    // good request
    }.invalidToken {
    // bad request
    }





    withFormat

    Purpose

    Used to execute different responses based on the incoming request Accept header, format parameter or URI extension. See content negotiation for more information.

    Examples

    import grails.converters.*
    

    class BookController { def books def list = { this.books = Book.list() withFormat { html bookList:books js { render "alert('hello')" } xml { render books as XML } } } }

    Description

    The withFormat method takes a block within the scope of which you can execute different methods whose names match the content type you want to respond to. For example:

    withFormat {
    html bookList:books
    js { render "alert('hello')" }
    xml { render books as XML }
    }

    Here we invoke three methods called html, js and xml that use mime type names configured in grails-app/conf/Config.groovy (See content negotiation for more information). The call to html accepts a model (a map) which is passed on to the view. Grails will first search for a view called grails-app/views/book/list.html.gsp and if that is not found fallback to grails-app/views/book/list.gsp.

    Note that the order of the types is significant if either the request format is "all" or more than one content type has the same "q" rating in the accept header. In the former case, the first type handler in the block is executed ("html" in the short example above). The latter case is more confusing because it only holds if there is more than one content type with the highest "q" rating for which you have a type handler and you have more than one type handler matching that "q" rating. For example, say the request has "text/html" and "application/xml" with a "q" rating of 1.0, then this code:

    withFormat {
    xml { … }
    html { … }
    }


    天蒼蒼,野茫茫,風(fēng)吹草底見(jiàn)牛羊

    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     

    posts - 80, comments - 24, trackbacks - 0, articles - 32

    Copyright © asdtiang

    asdtiang的博客 PaidMailz
    點(diǎn)擊廣告網(wǎng)賺A(每天4個(gè)廣告,每個(gè)0.0025美元,一個(gè)搜索廣告0.03美元)
    主站蜘蛛池模板: 亚洲免费视频在线观看| 日产国产精品亚洲系列| 亚洲AV永久无码精品一福利| 亚洲第一福利网站在线观看| 久久免费观看国产99精品| 亚洲一区二区三区免费视频| 免费观看国产精品| 最近中文字幕mv免费高清在线| 亚洲日本天堂在线| 亚洲va久久久噜噜噜久久| 男女交性永久免费视频播放| 免费视频成人手机在线观看网址| 中日韩亚洲人成无码网站| 亚洲国产婷婷六月丁香| 大学生a级毛片免费观看 | 国产精品无码亚洲精品2021| 国产亚洲一区二区手机在线观看| 免费阿v网站在线观看g| 一区二区三区免费视频观看| 亚洲伊人久久大香线蕉在观| 久久久久亚洲av成人无码电影| 无限动漫网在线观看免费| 另类免费视频一区二区在线观看 | 污网站免费在线观看| 久久久亚洲裙底偷窥综合| 亚洲精品美女久久久久99小说| 99久久免费精品国产72精品九九| 四虎国产精品免费永久在线| 亚洲AV无码专区国产乱码不卡| 亚洲日本国产精华液| 亚洲精品国产精品乱码不卡√| 大胆亚洲人体视频| 在线免费观看视频你懂的| 99re6免费视频| 你是我的城池营垒免费看| 国产精品亚洲二区在线| 亚洲影视自拍揄拍愉拍| 久久久久亚洲av无码专区喷水 | 亚洲精品无码AV人在线播放| 免费国内精品久久久久影院| 日韩精品极品视频在线观看免费|