1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Application.cfcについて

Posted at

Application.cfc

Application.cfcは必ず最初に実行される。
どのコードをどのタイミングで実行するのか指定できる。今回はonRequestStart このタイミングでrequest.nameにhogeを入れる。

demo.htmlでrequest.nameを使うことができるし、ほかのhtmlでも共有して使うことができる。
普通はsessionとかcookieとかの記録をする。

注意:ファイル名のAは必ず大文字で。

コード

demo.html

<html lang="ja">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <cfoutput>#request.name#</cfoutput>
  
</body>
</html>

Application.cfc その①

<cfcomponent>

    <!---application名以外はデフォルト--->
    <cfset This.name = "MyApp">

    <!---cfmページが呼ばれたときに最初に必ず--->
    <cffunction name="onRequestStart">

        <cfset request.name = "hoge">
     
    </cffunction>

</cfcomponent>

Application.cfc その②

component {

    this.name = "MyApp";
  
    public void function onRequestStart() {
  

        var request.name = "taro";
  
    }
  
  }

参考

http://coldfusion.blog.shinobi.jp/coldfusionのタグ/application.cfcでエラー処理

https://gist.github.com/learncfinaweek/4121263

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?