小编Moo*_*ooh的帖子

Play Framework应用程序部署

它已经花了很长时间在一个游戏应用程序上工作,现在是时候部署它了.这是我的第一次,所以我有点失落.哪个托管公司是最好的,并提供良好的价格?

java deployment hosting web-applications playframework

22
推荐指数
4
解决办法
1万
查看次数

在Play Framework上生成管理区域(CRUD)

我正在遵循创建管理区域的官方教程.我正确地做了第​​一步但是当我将我的控制器类扩展到CRUD时,我得到了一个错误(在项目中找不到Crud)+ Access denied当我访问http:// localhost:9000/admin /时.这就是我做的:

  1. 为应用程序启用CRUD模块在/conf/application.conf文件中,通过添加以下行来启用CRUD模块:

    module.crud=${play.path}/modules/crud

    导入默认的CRUD路由

  2. 在conf/routes文件中,通过添加以下行来导入默认模块路由:

    * /admin module:crud

  3. 创建用户控制器

    package controllers;
    
    public class Users extends CRUD {
    
    }
    
    Run Code Online (Sandbox Code Playgroud)
  4. 重启播放和日食

有任何建议让管理区域工作吗?

java frameworks web-applications playframework

13
推荐指数
2
解决办法
6791
查看次数

将Apache公共依赖项添加到Play Framework 2.0

我想导入org.apache.commons.io但我收到此错误:

[info] Compiling 1 Java source to /home/ghost/Bureau/app/play-2.0.1/waf/target/scala-2.9.1/classes...
[error] /home/ghost/Bureau/app/play-2.0.1/waf/app/controllers/Application.java:9: error: package org.apache.commons.io does not exist
[error]     import org.apache.commons.io.*;
[error]     ^
[error] /home/ghost/Bureau/app/play-2.0.1/waf/app/controllers/Application.java:41: error: cannot find symbol
[error]                 FileUtils.copyFile(file, destinationFile);
[error]                 ^
[error]   symbol:   variable FileUtils
[error]   location: class Application
[error] 2 errors
[error] {file:/home/ghost/Bureau/app/play-2.0.1/waf/}waf/compile:compile: javac returned nonzero exit code
[error] application - 
Run Code Online (Sandbox Code Playgroud)

玩找不到包org.apache.commons.io.我怎样才能添加apache作为依赖?

java scala playframework playframework-2.0

10
推荐指数
1
解决办法
8590
查看次数

路由到播放中的静态文件!框架2.0

对于搜索引擎优化的目的,我想让一些文件可以访问网址,如http://example.ca/robots.txt,但我遇到了一个奇怪的问题.这些文件可以通过firefox访问,但Chrome和谷歌机器人无法获取这些文件!

我的路线:

# Map static resources from the /public folder to the /assets URL path
GET     /assets/*file               controllers.Assets.at(path="/public", file)

# Robots and Humans files
GET     /$file<(robots|humans).txt>             controllers.Assets.at(path="/public", file)

GET     /$file<MJ12_576CD562EFAFA1742768BA479A39BFF9.txt>                 controllers.Assets.at(path="/public", file)
Run Code Online (Sandbox Code Playgroud)

model-view-controller routing playframework playframework-2.0

9
推荐指数
1
解决办法
3745
查看次数

多个图片上传(Play Framework)

我试图允许用户上传多个图像,但当我用一些文件验证表单时,我得到此错误 图像字段上的值不正确 ...这是我的代码:

在视图中:

 #{form @save(id)}

    #{ifErrors}
        <p class="error">
            Please correct these errors.
        </p>
    #{/ifErrors}

    <p>
        <label>Titre</label>
        <input type="text" name="title" value="${flash.title}" id="title" />
        <span class="error">#{error 'title' /}
    </p>
    <p>
        <label>Description</label>
        <textarea name="detail" value="${flash.detail}" id="detail" /></textarea>
        <span class="error">#{error 'detail' /}
    </p>

    <p>
        <label>Photos</label>
        <input type="file" draggable="true" name="files" id="files" multiple="multiple"/> 
        <strong>(Max. 5 photos)</strong> <span class="error">#{error 'files' /}
    </p>
    <p>
        <input type="submit" value="Publier l'annonce" />
    </p>

 #{/form}
Run Code Online (Sandbox Code Playgroud)

java函数:

    public static void save(long id, @Required String title, @Required String detail, File[] files) throws …
Run Code Online (Sandbox Code Playgroud)

java file-upload web-applications playframework

4
推荐指数
1
解决办法
5514
查看次数

将java对象保存到PostgreSQL

我想将我的java对象保存到postgresql列,我正在寻找一种简单的方法.

  1. 列存储对象的类型是什么?
  2. 我听说过序列化,但我有点迷茫.我如何序列化/反序列化对象?

java sql postgresql serialization jdbc

3
推荐指数
1
解决办法
1万
查看次数

推广一个简单的线性时间算法

我正在尝试写一个线性时间算法O(n),它给出一个表A [0..n-1] (用升序自然值填充)检查是否有一对A [i],A [j]满足f(A [i],A [j])= C (C是预定常数).

假设f(a,b)= a + b算法将是:

Algo Paires(A[0..N-1], C)
in: Tab A[0..n-1] and C a constant
out : Boolean
Init indice ? 0
For i ? 0..n-1 do 
    if indice ? i & A[indice] + A[i] = C 
      return true
    else if i = n-1 & indice ? n-2 
      indice++; i ? 0;
End for
return False
Run Code Online (Sandbox Code Playgroud)

但如果:

在此输入图像描述

算法会是什么呢?有什么建议 ?

algorithm data-structures

3
推荐指数
1
解决办法
201
查看次数

RadioButtons无法在动态创建的RadioGroup中正确选择/取消选择

当我在XML布局文件中创建一个RadioGroup时,一切都很好,但是当我动态创建它时,RadioButtons在选择另一个时不会取消选择:

在此输入图像描述

这是代码:

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    RadioGroup radioGroup = (RadioGroup) findViewById(R.id.radioGroup1);

    RadioButton radioButtonView = new RadioButton(this);
    radioButtonView.setText("RadioButton");
    radioGroup.addView(radioButtonView);

    RadioButton radioButtonView2 = new RadioButton(this);
    radioButtonView2.setText("RadioButton2");
    radioGroup.addView(radioButtonView2);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}
}
Run Code Online (Sandbox Code Playgroud)

和布局文件:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<RadioGroup
    android:id="@+id/radioGroup1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true" >
</RadioGroup>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

java android radio-group radio-button

3
推荐指数
1
解决办法
1029
查看次数

使用Play 2.0.x进行永久重定向

我想知道如何在Play框架2.0.x中为子域进行永久重定向301.例如:www.example.com/*重定向到example.com/*.以前有人试过吗?

java scala playframework playframework-2.0

3
推荐指数
2
解决办法
1829
查看次数

将java对象保存为PostgreSQL问题

我正在尝试使用以下代码将对象保存在postgre列(bytea)中:

Utilisateur utilisateur = new Utilisateur("aa","aa","aa",10,"aaammm",12,Role.ADMINISTRATEUR);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(utilisateur);
        oos.close();
        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());

        Connection connection = null;
        PreparedStatement preparedStatement = null;


        connection = Connect();
        String SOME_SQL= "INSERT INTO test (id, objet) VALUES( ?, ?)";
        preparedStatement = connection.prepareStatement(SOME_SQL);
        preparedStatement.setBinaryStream(2, bais);
        preparedStatement.setInt(1, 11);
        preparedStatement.executeUpdate();
        preparedStatement.close();
Run Code Online (Sandbox Code Playgroud)

但我得到了这个例外:

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
    at org.eclipse.ve.internal.java.vce.launcher.remotevm.JavaBeansLauncher.main(JavaBeansLauncher.java:86)
Caused by: org.postgresql.util.PSQLException: Function org.postgresql.jdbc4.Jdbc4PreparedStatement.setBinaryStream(int, InputStream) is not implemented.
    at org.postgresql.Driver.notImplemented(Driver.java:753)
    at org.postgresql.jdbc4.AbstractJdbc4Statement.setBinaryStream(AbstractJdbc4Statement.java:129)
    at com.grst.connector.SerializeToDatabase.<init>(SerializeToDatabase.java:35) …
Run Code Online (Sandbox Code Playgroud)

java sql postgresql serialization jdbc

2
推荐指数
1
解决办法
4463
查看次数

在play框架2上使用ManyToOne字段绑定表单请求

当我向模型"Item"添加一个多字段字段时,我收到此错误,并尝试绑定相应的表单.

Execution exception
[IllegalStateException: No value] at line 31

=> Item item = itemForm.bindFromRequest().get();
Run Code Online (Sandbox Code Playgroud)

"物品" 型号:包装型号;

@Entity 
public class Item extends Model {

    @Id
    public Long id;

    @ManyToOne
    @Constraints.Required
    @Formats.NonEmpty
    public Category category;

    @Constraints.Required
    public String title;

    @Constraints.Required
    public String content;

    public String picture;

    (..)    
}
Run Code Online (Sandbox Code Playgroud)

表格查看:

    @helper.form(action = routes.Application.newItem(), 'id -> "item_form", 'method -> "POST", 'enctype -> "multipart/form-data"){
    <fieldset>
        @helper.inputText(
        itemForm("title"),
        '_label -> "Titre"  )

        @helper.select(
        itemForm("category"), 
        helper.options(Category.list),
        '_label -> "Categorie")

        @helper.textarea(
        itemForm("content"),
        '_label -> "Description") …
Run Code Online (Sandbox Code Playgroud)

java scala playframework playframework-2.0

2
推荐指数
1
解决办法
2006
查看次数

开始一项新活动(android)

我想从主要的一个开始一个新的活动但是当应用程序启动应用程序时出现错误...已经意外停止了.请再试一次(在eclipse上没有错误).这是我的代码:

public class clubber extends Activity {
    protected SearchData sData ;
    protected boolean club;
    protected boolean resto;
    protected boolean bar;
    protected String searchTerms;
    protected String city;
    protected String distance;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

       (...)

        //Search button action 
        final Button button = (Button) findViewById(R.id.search);
        button.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                // Perform action on clicks
                Toast.makeText(clubber.this, "Let's find something !", Toast.LENGTH_SHORT).show(); …
Run Code Online (Sandbox Code Playgroud)

java eclipse android android-emulator android-activity

1
推荐指数
1
解决办法
1万
查看次数

使用Play Framework从html选择表单中检索数据

正如标题所说,我正在尝试从html选择表单中检索所选项目.我尝试使用以下代码执行此操作,但它不起作用!城市值始终为NULL但地址字段返回正确的值...

form.html:

#{extends '/Admin/admin.html' /}
 #{form @save(id)}

    #{ifErrors}
        <p class="error">
            Please correct these errors.
        </p>
    #{/ifErrors}

    <p>
        <label>Adresse</label>
        <input type="text" name="adress" value="${flash.adress}" id="adress" />
        <span class="error">#{error 'adress' /}
    </p>
    <p>
        <label>Ville</label>
        <select size="1" >
            #{list items:cities, as:'city'}
                <option name="city" id="city" value="${flash.city}">${city}</option>
            #{/list}
        </select>
        <span class="error">#{error 'city' /}
    </p>
    <p>
        <input type="submit" value="Publier l'annonce" />
    </p>

 #{/form}
Run Code Online (Sandbox Code Playgroud)

保存方法:

public static void save(long id, String adress, @Required Place city){ 
    System.out.println(city);
    Admin.index();
}
Run Code Online (Sandbox Code Playgroud)

java select playframework

0
推荐指数
1
解决办法
6169
查看次数