您好我正在尝试将models.InputTimeSheetDataStore
类型的对象列表从视图传递到application.java,我收到No QueryString binder found for type java.util.List[models.InputTimeSheetDataStore]. Try to implement an implicit QueryStringBindable for this type
错误
我传递了要查看的对象列表
InputTimeSheetDataStore ITSDS= new InputTimeSheetDataStore();
ITSDS.ConsultantName=EmployeeFilter;
ITSDS.Client=ClientFilter;
ITSDS.Project=ProjectFilter;
ITSDS.Role=EmployeeRoleFilter;
ITSDS.Task=Task;
ITSDS.TimeSheetDate=TimeSheetDate;
ITSDS.Hours=TaskHours;
ITSDS.IsBilled=IsBilled;
ITSDS.Workplace=WorkPlace;
InputTimeSheetList.add(ITSDS);
return ok(TimeSheetInput.render(Consultant.PopulateConsultant(),Client.PopulateClient(),Project.PopulateProject(ClientFilter),
Consultant.PopulateConsultantRole(),Consultant.ConsultantRoleRate(EmployeeRoleFilter),InputTimeSheetList));
在视图中我将该对象传递回application.java
@(EmployeeList:java.util.List[String],ClientList:java.util.List[String],
ProjectList:java.util.List[String],EmployeeRoleList: java.util.List[String],Rate:String,
CurrentPage:List[InputTimeSheetDataStore])
<form id="TimeSheetEntryForm" name="TimeSheetEntryForm" action="@{routes.Application.save("name","name","name","name","name","name","name","name","name",CurrentPage)}" method="GET">
<code.....>
这是我的班级文件
InputTimeSheetDataStore.java
package models;
public class InputTimeSheetDataStore {
public String ConsultantName;
public String Client;
public String Project;
public String Role;
public String Task;
public String TimeSheetDate;
public String Hours;
public String IsBilled;
public String Workplace;
public String getConsultantName(){
return this.ConsultantName;
}
public String getClient(){
return this.Client;
}
public String getProject(){
return this.Project;
}
public String getRole(){
return this.Role;
}
public String getTask(){
return this.Task;
}
public String getTimeSheetDate(){
return this.TimeSheetDate;
}
public String getHours(){
return this.Hours;
}
public String getIsBilled(){
return this.IsBilled;
}
public String getWorkPlace(){
return this.Workplace;
}
}
我的路线是
GET /Application/save controllers.Application.save(EmployeeFilter:String,ClientFilter:String,ProjectFilter:String, EmployeeRoleFilter:String,Task:String,TaskHours:String,TimeSheetDate:String,IsBilled:String,WorkPlace:String,CurrentPage:java.util.List[models.InputTimeSheetDataStore])
有人可以帮我使用InputTimeSheetDataStore类型的隐式查询绑定器
提前致谢
答案 0 :(得分:0)
嗨,这是QueryStringbindable的示例实现:
public class InputTimeSheetDataStore implements QueryStringBindable<InputTimeSheetDataStore> {
public String consultantName, client, project;
@Override
public Optional bind(String key, Map data) {
if (data.containsKey("consultantName")) {
this. consultantName = data.get("consultantName").toString();
}
if (data.containsKey("client")) {
this.client = data.get("client").toString();
}
if (data.containsKey("project")) {
this.project = data.get("project").toString();
}
return Optional.of(this);
}
@Override
public String unbind(String key) {
return null;
}
@Override
public String javascriptUnbind() {
return null;
}
}
为您提供的其他提示,在编写编程语言时,请确保遵循代码约定。例如:Java语法中的约定,您必须为第一个字符写小写的变量;
public String ConsultantName; // this is wrong
public String consultantName; //this is right
希望有帮助。