{"id":278,"date":"2013-05-29T08:00:49","date_gmt":"2013-05-28T23:00:49","guid":{"rendered":"http:\/\/www.beeete2.com\/blog\/?p=278"},"modified":"2020-01-29T23:40:15","modified_gmt":"2020-01-29T14:40:15","slug":"playframework2%e3%81%ae%e3%83%86%e3%83%b3%e3%83%97%e3%83%ac%e3%83%bc%e3%83%88%e5%86%85%e3%81%a7%e7%b9%b0%e3%82%8a%e8%bf%94%e3%81%97","status":"publish","type":"post","link":"https:\/\/www.beeete2.com\/blog\/?p=278","title":{"rendered":"playframework2\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5185\u3067\u7e70\u308a\u8fd4\u3057"},"content":{"rendered":"<p>\u524d\u56de\u304b\u3089\u306e\u7d9a\u304d\u3067\u3059\u3002<br \/>\nTwitter\u304b\u3089\u53d6\u5f97\u3057\u305f\u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u3092\u8868\u793a\u3059\u308b\u90e8\u5206\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\n\u53d6\u5f97\u3057\u305f\u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u3092\u7e70\u308a\u8fd4\u3057\u8868\u793a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u3068\u3044\u3046\u308f\u3051\u3067\u3001\u4eca\u56de\u306fPlayframework2\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5185\u3067\u7e70\u308a\u8fd4\u3057\u306a\u3069\u306e\u5236\u5fa1\u3092\u3057\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h2>Twitter\u7528\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210<\/h2>\n<p>\u57fa\u672c\u7684\u306b\u3001Twitter4j\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f7f\u3044\u307e\u3059\u304c\u3001\u96c6\u7d04\u3059\u308b\u305f\u3081\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u308a\u307e\u3059\u3002<br \/>\ntwitter\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u4f5c\u6210\u3057\u3066\u3001TwitterInfo\u3068\u3044\u3046\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<br \/>\n\u53d6\u308a\u6025\u304e\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>[java]<br \/>\npackage twitter;<\/p>\n<p>public class TwitterInfo {<br \/>\n\tpublic String screen_name;<br \/>\n\tpublic String description;<br \/>\n\tpublic List&lt;Tweet&gt; tweets;<br \/>\n}<br \/>\n[\/java]<\/p>\n<p>\u3082\u3046\u4e00\u3064\u3001\u30c4\u30a4\u30fc\u30c8\u60c5\u5831\u3092\u4fdd\u6301\u3059\u308b\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>[java]<br \/>\npublic class Tweet {<br \/>\n\tpublic String text;<br \/>\n}<br \/>\n[\/java]<\/p>\n<p>\u3068\u308a\u3042\u3048\u305a\u3001\u4eca\u306f\u3053\u308c\u3067\u3002\u5f8c\u304b\u3089\u8272\u3005\u8ffd\u52a0\u3059\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<h2>Playframework2\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u5f15\u6570\u3092\u5909\u66f4<\/h2>\n<p>\u3053\u308c\u304c\u3001\u30cf\u30de\u308a\u307e\u3057\u305f\u3002<br \/>\nscala\u306e\u30a4\u30f3\u30dd\u30fc\u30c8\u65b9\u6cd5\u8abf\u3079\u3066\u3001\u66f8\u3044\u305f\u3093\u3067\u3059\u3051\u3069\u3001\u8a8d\u8b58\u3057\u3066\u304f\u308c\u306a\u304f\u3066\u30fb\u30fb\u30fb\u3002<\/p>\n<p>[scala]<br \/>\n@(twitter_info: TwitterInfo)<br \/>\n@import twitter._<br \/>\n[\/scala]<\/p>\n<p>\u4f7f\u3063\u3066\u3044\u308b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u5f8c\u306b\u30a4\u30f3\u30dd\u30fc\u30c8\u6587\u304c\u3042\u308b\u306e\u3067\u3001\u30c0\u30e1\u306a\u3093\u3067\u3057\u3087\u3046\u3051\u3069\u3002\u30a4\u30f3\u30dd\u30fc\u30c8\u6587\u3092\u4e0a\u306b\u6301\u3063\u3066\u3044\u3066\u3082\u30c0\u30e1\u3060\u3063\u305f\u306e\u3067\u3001\u8ae6\u3081\u307e\u3057\u305f\u3002\u5f8c\u307b\u3069\u3001\u8981\u8abf\u67fb\u3002<br \/>\nproject\/Build.scala\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u304c\u3042\u308b\u306e\u3067\u3001\u3053\u3061\u3089\u306b\u30a4\u30f3\u30dd\u30fc\u30c8\u6587\u3092\u8a18\u8f09\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>[scala]<br \/>\n  val main = play.Project(appName, appVersion, appDependencies).settings(<br \/>\n    \/\/ Add your own project settings here<br \/>\n    templatesImport += &quot;twitter._&quot;<br \/>\n  )<br \/>\n[\/scala]<\/p>\n<p>\u3053\u308c\u3067\u3001\u7121\u4e8b\u306b\u30b3\u30f3\u30d1\u30a4\u30eb\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<h2>Application.java\u306e\u4fee\u6b63<\/h2>\n<p>\u3053\u308c\u3067\u3001\u8981\u7d04Application.java\u306e\u4fee\u6b63\u3092\u884c\u3048\u307e\u3059\u30fb\u30fb\u30fb\u3002<br \/>\ntimeline\u30e1\u30bd\u30c3\u30c9\u3092\u4fee\u6b63\u3057\u307e\u3059\u3002<\/p>\n<p>\u3068\u308a\u3042\u3048\u305a\u78ba\u8a8d\u304c\u76ee\u7684\u306a\u306e\u3067\u3001Twitter\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u305b\u305a\u306b\u3001\u81ea\u4f5c\u81ea\u6f14\u3057\u307e\u3059\u3002<\/p>\n<p>[java]<br \/>\n    public static Result timeline() {<br \/>\n    \tTwitterInfo ti = new TwitterInfo();<br \/>\n    \tti.screen_name = &quot;\u30c6\u30b9\u30c8\uff08\u540d\u524d\uff09&quot;;<br \/>\n    \tti.description = &quot;\u30c6\u30b9\u30c8\uff08\u6982\u8981\uff09&quot;;<\/p>\n<p>    \tList&lt;Tweet&gt; tweets = new ArrayList&lt;Tweet&gt;();<br \/>\n    \ttweets.add(createTweet(&quot;1\u30c4\u30a4\u30fc\u30c8&quot;));<br \/>\n    \ttweets.add(createTweet(&quot;2\u30c4\u30a4\u30fc\u30c8&quot;));<br \/>\n    \ttweets.add(createTweet(&quot;3\u30c4\u30a4\u30fc\u30c8&quot;));<br \/>\n    \ttweets.add(createTweet(&quot;4\u30c4\u30a4\u30fc\u30c8&quot;));<br \/>\n    \tti.tweets = tweets;<\/p>\n<p>    \treturn ok(timeline.render(ti));<br \/>\n    }<\/p>\n<p>    private static Tweet createTweet(String text) {<br \/>\n    \tTweet tweet = new Tweet();<br \/>\n    \ttweet.text = text;<\/p>\n<p>    \treturn tweet;<br \/>\n    }<br \/>\n[\/java]<\/p>\n<h4>timeline.scala.html\u306e\u4fee\u6b63<\/h4>\n<p>\u304a\u5f85\u305f\u305b\u3057\u307e\u3057\u305f\u3002\u3053\u308c\u3067\u3088\u3046\u3084\u304f\u672c\u8a18\u4e8b\u306e\u30e1\u30a4\u30f3\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5185\u3067\u306e\u7e70\u308a\u8fd4\u3057\u304c\u884c\u3048\u307e\u3059\u3002\u9577\u304b\u3063\u305f\u30fb\u30fb\u30fb\u3002<\/p>\n<p>\u7e70\u308a\u8fd4\u3057\u306e\u66f8\u304d\u65b9\u306f\u5358\u7d14\u3067\u3001@for(){}\u3067\u3059\u3002\u307e\u3041\u3001<br \/>\n\u3061\u306a\u307f\u306b\u3001\u3053\u306e\u4e2d\u3067\u5206\u5c90\u3068\u304b\u3067\u304d\u308b\u306e\u304b\u306a\u3002\u307e\u305f\u4eca\u5ea6\u8abf\u3079\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>[html]<br \/>\n@(twitter_info: TwitterInfo)<br \/>\n@main(&quot;Welcome to Play 2.1&quot;) {<br \/>\n      &lt;!&#8211; Main hero unit for a primary marketing message or call to action &#8211;&gt;<br \/>\n      &lt;div class=&quot;hero-unit&quot;&gt;<br \/>\n        &lt;h1&gt;@twitter_info.screen_name&lt;\/h1&gt;<br \/>\n        &lt;p&gt;@twitter_info.description&lt;\/p&gt;<br \/>\n        &lt;p&gt;&lt;a href=&quot;#&quot; class=&quot;btn btn-primary btn-large&quot;&gt;Learn more &amp;raquo;&lt;\/a&gt;&lt;\/p&gt;<br \/>\n      &lt;\/div&gt;<br \/>\n      &lt;!&#8211; Example row of columns &#8211;&gt;<br \/>\n      &lt;div class=&quot;row&quot;&gt;<br \/>\n      @for(tweet &lt;- twitter_info.tweets) {<br \/>\n        &lt;div class=&quot;span4&quot;&gt;<br \/>\n          &lt;p&gt;@tweet.text&lt;\/p&gt;<br \/>\n          &lt;p&gt;&lt;a class=&quot;btn&quot; href=&quot;#&quot;&gt;View details &amp;raquo;&lt;\/a&gt;&lt;\/p&gt;<br \/>\n        &lt;\/div&gt;<br \/>\n      }<br \/>\n      &lt;\/div&gt;<br \/>\n}<br \/>\n[\/html]<\/p>\n<h2>\u5b9f\u884c\u3057\u3066\u307f\u308b<\/h2>\n<p><a href=\"https:\/\/www.beeete2.com\/blog\/wp-content\/uploads\/2013\/05\/Welcome-to-Play-2.1-4.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-290\" src=\"https:\/\/www.beeete2.com\/blog\/wp-content\/uploads\/2013\/05\/Welcome-to-Play-2.1-4.jpg\" alt=\"Welcome to Play 2.1-4\" width=\"988\" height=\"471\" srcset=\"https:\/\/www.beeete2.com\/blog\/wp-content\/uploads\/2013\/05\/Welcome-to-Play-2.1-4.jpg 988w, https:\/\/www.beeete2.com\/blog\/wp-content\/uploads\/2013\/05\/Welcome-to-Play-2.1-4-300x143.jpg 300w, https:\/\/www.beeete2.com\/blog\/wp-content\/uploads\/2013\/05\/Welcome-to-Play-2.1-4-624x297.jpg 624w\" sizes=\"(max-width: 988px) 100vw, 988px\" \/><\/a><br \/>\nApplication.java\u306b\u66f8\u3044\u305f\u5185\u5bb9\u304c\u8868\u793a\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u8868\u793a\u3055\u305b\u3066\u3044\u308b\u5185\u5bb9\u304c\u5358\u7d14\u306a\u306e\u3067\u3001\u306a\u3093\u3068\u3082\u8a00\u3048\u306a\u3044\u3067\u3059\u304c\u3001\u3068\u308a\u3042\u3048\u305a\u30a4\u30f3\u30dd\u30fc\u30c8\u306e\u90e8\u5206\u3067\u304b\u306a\u308a\u6642\u9593\u3092\u5272\u3044\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002<br \/>\n\u591a\u5206\u3067\u3059\u304c\u3001\u5f15\u6570\u3067\u4f7f\u7528\u3059\u308b\u30af\u30e9\u30b9\u306f\u30b0\u30ed\u30fc\u30d0\u30eb\u3067\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3066\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5185\u90e8\u3067\u4f7f\u7528\u3059\u308b\u30af\u30e9\u30b9\u306f\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5185\u3067\u30a4\u30f3\u30dd\u30fc\u30c8\u3067\u5927\u4e08\u592b\u3058\u3083\u306a\u3044\u304b\u306a\u30fc\u3068\u3001\u52dd\u624b\u306b\u601d\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u56de\u304b\u3089\u306e\u7d9a\u304d\u3067\u3059\u3002 Twitter\u304b\u3089\u53d6\u5f97\u3057\u305f\u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u3092\u8868\u793a\u3059\u308b\u90e8\u5206\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002 \u53d6\u5f97\u3057\u305f\u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u3092\u7e70\u308a\u8fd4\u3057\u8868\u793a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 \u3068\u3044\u3046\u308f\u3051\u3067\u3001\u4eca\u56de\u306fPlayframework2\u306e\u30c6\u30f3 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[92],"tags":[6],"views":3338,"_links":{"self":[{"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/278"}],"collection":[{"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=278"}],"version-history":[{"count":16,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/278\/revisions"}],"predecessor-version":[{"id":2478,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/278\/revisions\/2478"}],"wp:attachment":[{"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=278"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=278"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}