Sono nuovo con la riproduzione 2.0. Ho creato un modulo di iscrizione e ora provo a creare un modulo di ricerca. Ma sono stato catturato da questo error: " Missing parameter in call definition: String In /home/thangnk/Task/conf/routes at line 17. "
.Errore Parametro mancante nella definizione della chiamata: stringa
Ecco il mio codice:
CONTROLLER --- Search.java
package controllers;
import java.util.ArrayList;
import java.util.List;
import models.Task;
import play.*;
import play.data.Form;
import play.db.ebean.Model.Finder;
import play.mvc.*;
import views.html.*;
public class Search extends Controller{
static Form<Task> myform = form(Task.class);
public static Result search(){
return ok(search.render());
}
public static Result searchByusername(String username){
Form<Task> filledForm = myform.bindFromRequest();
username=filledForm.get().username;
return ok(result_search.render(username));
}
}
MODELLI --- Task.java
package models;
import java.util.*;
import javax.persistence.Entity;
import javax.persistence.Id;
import play.data.validation.Constraints.Email;
import play.data.validation.Constraints.MaxLength;
import play.data.validation.Constraints.MinLength;
import play.data.validation.Constraints.Required;
import play.db.ebean.Model;
import play.db.ebean.Model.Finder;
@Entity
public class Task extends Model {
@Id
public static Long id;
// @Required
// @MinLength(6)
// @MaxLength(12)
public String password;
@Email
public String email;
// @MinLength(6)
public String username;
public Task() {
}
public Task(Long id, String username, String email, String password) {
this.email = email;
this.username = username;
this.id = id;
this.password = password;
}
public static Finder<Long, Task> find = new Finder(Long.class, Task.class);
public static List<Task> all() {
return find.all();
}
public static void create(Task task) {
task.save();
}
public static void delete(Long id) {
find.ref(id).delete();
}
public static List<Task> searchByusername(String name) {
return find.where().like("username", "%" + name + "%").findList();
}
}
PERCORSI
GET / controllers.Application.index()
GET /tasks controllers.Application.tasks()
POST /tasks controllers.Application.newTask()
POST /tasks/:id/delete controllers.Application.deleteTask(id:Long)
# POST /showuser controllers.Application.showUser()
# Search
GET /search controllers.Search.search()
POST /result_search/:String controllers.Search.searchByusername(username:String)
-------// This error mark at line "username : String" ----------------------------------
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.at(path="/public", file)
TERMINAL ----
[error] {file:/home/thangnk/Task/}Task/compile:sources: in /home/thangnk/Task/conf/routes - PlayException: Compilation error [Missing parameter in call definition: String]
[error] application -
! Internal server error, for request [GET /search] ->
sbt.PlayExceptions$RoutesCompilationException: Compilation error [Missing parameter in call definition: String]
at sbt.PlayCommands$$anonfun$52.apply(PlayCommands.scala:433) ~[na:na]
at sbt.PlayCommands$$anonfun$52.apply(PlayCommands.scala:423) ~[na:na]
at sbt.Scoped$$anonfun$hf3$1.apply(Structure.scala:474) ~[na:na]
at sbt.Scoped$$anonfun$hf3$1.apply(Structure.scala:474) ~[na:na]
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:41) ~[scala-library.jar:0.11.3]
at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$11.apply(Structure.scala:295) ~[na:na]
Speranza u ragazzi mi aiutano risolto e mi aiutano a compilare questo modulo.
prega di mostrare la traccia stack completo, al fine di individuare il codice difettoso. –
sry. Ho modificato: D –