playframework-2.0

Play framework, inserting initial-data more than 20 items per one Model

好久不见. 提交于 2020-01-05 10:07:08
问题 In the development mode of Play framework, I inserted my initial-data.yml through Global.java. However, if one model has more than 20 items, autu-generated IDs is going crazy. For example, if I had: computers: - !!models.Computer name: apple01 - !!models.Computer name: apple02 - !!models.Computer name: apple03 - !!models.Computer name: apple04 ... - !!models.Computer name: apple20 - !!models.Computer name: apple21 - !!models.Computer name: apple22 From 1 to 20, they got correct auto-generated

Escape semicolon route playframework 2.0.2

僤鯓⒐⒋嵵緔 提交于 2020-01-05 07:27:22
问题 I would like to do a redirect function with playframework. So far I have this in my routes GET /redirect com.test.redirect(redirecturl: String?="") and my controller : public static Result redirect(String redirecturl) { return redirect(redirectURL); } This is working well but I have a problem when I pass a url containing a semicolon ";" If I go to http:localhost:9000/redirect?redirecturl=http://www.google.com;testaftersemicolon It redirect me to google.com but in my log the redirecturl is

Escape semicolon route playframework 2.0.2

﹥>﹥吖頭↗ 提交于 2020-01-05 07:27:18
问题 I would like to do a redirect function with playframework. So far I have this in my routes GET /redirect com.test.redirect(redirecturl: String?="") and my controller : public static Result redirect(String redirecturl) { return redirect(redirectURL); } This is working well but I have a problem when I pass a url containing a semicolon ";" If I go to http:localhost:9000/redirect?redirecturl=http://www.google.com;testaftersemicolon It redirect me to google.com but in my log the redirecturl is

CSS in Play Framework 2.0.3

╄→尐↘猪︶ㄣ 提交于 2020-01-05 07:12:34
问题 I'm having some problems using CSS in Play Framework 2.0.3, and was wondering if anyone could spot the mistakes I am making. I have a view called siteview.scala.html, defined as: @(name: String, records: List[Record]) @import helper._ @main(name) { <html> <head> <link rel="stylesheet" type="text/css" href="@routes.Assets.at("stylesheets/main.css")"> </head> <h1>@name</h1> <ul> ... </ul> </html> } I have a CSS file defined as main.less in app/assets/stylesheets which looks like: h1 {color:

Request-response life cycle in Play(Scala) 2.4.X

白昼怎懂夜的黑 提交于 2020-01-05 04:25:11
问题 Few days back, I faced issue where client was receiving response from play application after 20 seconds. I have new relic set on production server which keeps telling about RPM, average response time, CPU and memory usage, etc. As per new relic response time was not exceeding 500 milli-seconds, but I verified that client was receiving response after 20 seconds. To dig out more I added logs in that tells about time required to serve request in play application. I added logs Filter as per

Play 2 Java authenticate plugin - HTTP status code response instead of redirect

左心房为你撑大大i 提交于 2020-01-05 04:03:32
问题 We are using Play 2 authenticate plugin for a REST API and I would like to simply return 200 or 403 for login attempts. The plugin's code looks like this: public static Result loginAndRedirect(final Context context, final AuthUser loginUser) { storeUser(context.session(), loginUser); return Controller.redirect(getJumpUrl(context)); } Is there any way to avoid the redirect without forking the plugin project? 回答1: I ended up handling this at the controller: public static Result login() { Result

Wrong Charset Encoding with Play Framework 2.1

拟墨画扇 提交于 2020-01-04 14:22:12
问题 I have a web service that receives a parameter in ISO-8859-1 encoding. But when I try to read it from the request, I get this characters: ����� I've tryied all these approaches, but none of the convert the given string to the expected one (áéíóú): val a = new String(_html.getBytes()); val b = new String(_html.getBytes(), "UTF-8") val c = new String(_html.getBytes(), "ISO-8859-1") val d = new String(_html.getBytes("ISO-8859-1"), "UTF-8") val e = new String(_html.getBytes("ISO-8859-1"), "ISO

Play framework 2.0.1 - Server only responding to the first requests

两盒软妹~` 提交于 2020-01-04 09:06:10
问题 I have a strange behavior with either Play 2.0 or 2.0.1 : the first or first few requests are served quickly by the Play! server, but then it's not responding anymore. I reproduced the problem on several projects including the hello word sample application : - lauching "play run" - Go to http://localhost:9000 -> ok - Hit refresh a few times : the requests are locked, the browser is just loading. I have the same behavior with Firefox and Chrome. I guess it's a setup problem, and I may be

How do I invoke non-GET/POST HTTP methods in Play?

≯℡__Kan透↙ 提交于 2020-01-04 05:51:32
问题 I have a RESTful Play 2.0 application, and I'd like to call DELETE /sessions from a link in the browser. How do I do this? Rails has a convention of using a _method query parameter for non-GET/POST requests, but Play's documents don't mention this. Also, do I have to create a separate form or XMLHttpRequest in order to invoke the method from a link's href or is there something like Rails's data-method attribute? 回答1: You will not do that with common link. Cite from similar topic on Google

Play framework Route case insensitive

你说的曾经没有我的故事 提交于 2020-01-04 04:58:06
问题 We are currently working on Play 2.5.x We wanted to achive case insensitive routing to be done. Say for example GET /via/v1/organizations http.organizationApi() In the URL we wanted to achive http://localhost:9000/abc/v1/organizations http://localhost:9000/ABC/V1/OrganIZations Is the a way to achive this bu using regular expression? Can some one point to or provide me an example? 回答1: You can define a request handler to make the URL case insensitive. In this case, the following handler will