マルチスレッドを勉強しなおすために
Java
並行処理プログラミング
-その「基盤」と「最新API」を究める-
を買った。
2011年3月27日日曜日
2010年12月19日日曜日
HTML中のクエリパラメータについて -2-
HTML中のクエリパラメータについて書いたけど
その続き。
html中にあるhref属性にて
クエリ文字列の区切りを「&」としても「&」としても
どっちでもステータスバーには「&」と表示され、
リクエストは「&」で送信されます。
でも、javascriptのlocation.href, replaceなどを使った場合、
ブラウザによって挙動が異なります。
以下のようなコードを書いて実行すると、
※Internet Explorer 8で実験
→ 「&」が「&」となってリクエストが送信されます。
※Firefox 3.6.12で実験
→ 「&」が「&」のままリクエストが送信されます。
で、HTTPの仕様としてはどうなのだろうと思って調べたけど
どのページを見ていいか分からず...
たぶん「&」が正しいと思うんだけどなー
その続き。
html中にあるhref属性にて
クエリ文字列の区切りを「&」としても「&」としても
どっちでもステータスバーには「&」と表示され、
リクエストは「&」で送信されます。
でも、javascriptのlocation.href, replaceなどを使った場合、
ブラウザによって挙動が異なります。
以下のようなコードを書いて実行すると、
location.replace('http://search.yahoo.co.jp/search?p=href+smgl&aq=-1&oq=&ei=UTF-8&fr=top_ga1_sa&x=wrt');
IEの場合
※Internet Explorer 8で実験
→ 「&」が「&」となってリクエストが送信されます。
Firefoxの場合
※Firefox 3.6.12で実験
→ 「&」が「&」のままリクエストが送信されます。
で、HTTPの仕様としてはどうなのだろうと思って調べたけど
どのページを見ていいか分からず...
たぶん「&」が正しいと思うんだけどなー
2010年12月18日土曜日
HTML中のクエリパラメータについて
以下のページにあるように、html中に記述するときは、&ではなくて&
でも、リクエストを送信するときは、ちゃんと&で送信するように!
http://www.ietf.org/rfc/rfc1866.txt
8.2.1. The form-urlencoded Media Type
The default encoding for all forms is `application/x-www-form-
urlencoded'. A form data set is represented in this media type as
follows:
1. The form field names and values are escaped: space
characters are replaced by `+', and then reserved characters
are escaped as per [URL]; that is, non-alphanumeric
characters are replaced by `%HH', a percent sign and two
hexadecimal digits representing the ASCII code of the
character. Line breaks, as in multi-line text field values,
are represented as CR LF pairs, i.e. `%0D%0A'.
2. The fields are listed in the order they appear in the
document with the name separated from the value by `=' and
the pairs separated from each other by `&'. Fields with null
values may be omitted. In particular, unselected radio
buttons and checkboxes should not appear in the encoded
data, but hidden fields with VALUE attributes present
should.
NOTE - The URI from a query form submission can be
used in a normal anchor style hyperlink.
Unfortunately, the use of the `&' character to
separate form fields interacts with its use in SGML
attribute values as an entity reference delimiter.
For example, the URI `http://host/?x=1&y=2' must be
written `<a href="http://host/?x=1&y=2"' or `<a
href="http://host/?x=1&y=2">'.
HTTP server implementors, and in particular, CGI
implementors are encouraged to support the use of
`;' in place of `&' to save users the trouble of
escaping `&' characters this way.
でも、リクエストを送信するときは、ちゃんと&で送信するように!
http://www.ietf.org/rfc/rfc1866.txt
8.2.1. The form-urlencoded Media Type
The default encoding for all forms is `application/x-www-form-
urlencoded'. A form data set is represented in this media type as
follows:
1. The form field names and values are escaped: space
characters are replaced by `+', and then reserved characters
are escaped as per [URL]; that is, non-alphanumeric
characters are replaced by `%HH', a percent sign and two
hexadecimal digits representing the ASCII code of the
character. Line breaks, as in multi-line text field values,
are represented as CR LF pairs, i.e. `%0D%0A'.
2. The fields are listed in the order they appear in the
document with the name separated from the value by `=' and
the pairs separated from each other by `&'. Fields with null
values may be omitted. In particular, unselected radio
buttons and checkboxes should not appear in the encoded
data, but hidden fields with VALUE attributes present
should.
NOTE - The URI from a query form submission can be
used in a normal anchor style hyperlink.
Unfortunately, the use of the `&' character to
separate form fields interacts with its use in SGML
attribute values as an entity reference delimiter.
For example, the URI `http://host/?x=1&y=2' must be
written `<a href="http://host/?x=1&y=2"' or `<a
href="http://host/?x=1&y=2">'.
HTTP server implementors, and in particular, CGI
implementors are encouraged to support the use of
`;' in place of `&' to save users the trouble of
escaping `&' characters this way.
2010年11月22日月曜日
2010年11月11日木曜日
Mayaa ループ
前回は値の出力(属性への出力も)を実施したので、
今回はループ。
あとは、条件分岐をやれば、だいたいのページは生成できると思います。
さて、こんなテーブルを作りたいことありますよね。
たとえば、一覧出力画面とかで。
で、以下の状況を想定。
htmlは↓のかんじ
で、mayaaは↓のかんじ
ここでポイントなのが、<m:doBody />タグ。
これがないと、↓のようなhtml出力されてしまいます。
Mayaaのドキュメントには、以下のように書いてあります。
つまり、簡単にいうと、forプロセッサのボディを評価したければ、<m:doBody />を書け、と。
この場合だと、 を評価しないとinfoが使えませんので、ぜひ<m:doBody />を付けてください。
ちなみに、<m:for />にreplace="false"を付けないと、 が消えてしまい、
以下のようなhtmlが出力されてしまいます。
今回はループ。
あとは、条件分岐をやれば、だいたいのページは生成できると思います。
さて、こんなテーブルを作りたいことありますよね。
たとえば、一覧出力画面とかで。
で、以下の状況を想定。
- requestスコープに、listAddressというjava.util.List型のオブジェクトがある
- Listの中身はPOJOで、customerCode, customerName, customerAddressが存在する
htmlは↓のかんじ
で、mayaaは↓のかんじ
ここでポイントなのが、<m:doBody />タグ。
これがないと、↓のようなhtml出力されてしまいます。
Mayaaのドキュメントには、以下のように書いてあります。
割り当てられたタグのボディを処理します。for プロセッサなどタグのボディが有効なプロセッサで動作します。通常は明示的に使用することはありませんが、Mayaa ファイル側のボディに attribute 以外のプロセッサや空白 (タブ文字、改行を含む) 以外の文字列を記述した場合、doBody を使用しなければタグのボディが処理されません。
つまり、簡単にいうと、forプロセッサのボディを評価したければ、<m:doBody />を書け、と。
この場合だと、
ちなみに、<m:for />にreplace="false"を付けないと、
以下のようなhtmlが出力されてしまいます。
2010年11月9日火曜日
Mayaa 値の挿入
Mayaaについて書いてみる。
まあ、に書いてあるんだけど、
ここには、目的別に書いてみる。
●表示
みたいな出力をしたい場合があります。
もちろん、「○○」はセッション中の動的な値で。
そういうときは、
前提
●html
などと書きます。
もちろん、htmlの先頭には、
と書いておきます。
で、mayaaファイルには
javascript:void(0)
って書けばOKです。
上では要素として?の出力を書きましたが、
属性値に書きたい場合もありますね。
こんな場合を想定↓
●表示は省略。
テキストボックス中のvalueに出力したい場合
1. 想定するケースとしては、入力画面でsubmitしたあと、入力エラーがあって、画面を再表示する場合
2. 変更画面で、現在の値を入力しておいてあげる優しさを見せたいとき
そういうときは、
前提
●html
などと書きます。
で、mayaaファイルには
って書けばOKです。
これで、valueの中に動的な値を出力できます。
まあ、に書いてあるんだけど、
ここには、目的別に書いてみる。
セッション中の値を表示する
●表示
みたいな出力をしたい場合があります。
もちろん、「○○」はセッション中の動的な値で。
そういうときは、
前提
- セッション中にuserInfoオブジェクトが存在する
- userInfoにはuserName属性があり、そのgetter/setterが存在する(この場合setterは関係ないかも)
- ちなみにuserNameはjava.lang.String型である
●html
などと書きます。
もちろん、htmlの先頭には、
と書いておきます。
で、mayaaファイルには
javascript:void(0)
って書けばOKです。
value属性にセッション中の値を表示する
上では要素として?の出力を書きましたが、
属性値に書きたい場合もありますね。
こんな場合を想定↓
●表示は省略。
テキストボックス中のvalueに出力したい場合
1. 想定するケースとしては、入力画面でsubmitしたあと、入力エラーがあって、画面を再表示する場合
2. 変更画面で、現在の値を入力しておいてあげる優しさを見せたいとき
そういうときは、
前提
- セッション中にuserInfoオブジェクトが存在する
- userInfoにはuserName属性があり、そのgetter/setterが存在する(この場合setterは関係ないかも)
- ちなみにuserNameはjava.lang.String型である
●html
変更後のユーザ名:
などと書きます。
で、mayaaファイルには
って書けばOKです。
これで、valueの中に動的な値を出力できます。
2010年11月3日水曜日
Javaテンプレートエンジン [Mayaa]
登録:
投稿 (Atom)