gpt4 book ai didi

java - Play框架-简单表达式的非法启动

转载 作者:行者123 更新时间:2023-11-30 07:15:06 26 4
gpt4 key购买 nike

我正在尝试实现一个过滤器功能,该功能将按类型显示企业。这是“搜索表单”,用户可以在其中选择他们想要显示的业务类型

@(businessList: List[Business], formSearch: Form[Business])

@import helper._

@main("All businesses"){

@form(action=routes.Application.displayAllBusinesses("")){
@select(formSearch("type"),options(Seq("Dining","Accomodation","Manufacturing","Retail", "Services")),'_label ->"Business Type",'_default->"--Select a business type--")

<input type="submit" class="btn btn-success" value="Search by type">
<a class="btn" href="@routes.Application.displayAllBusinesses()">Show all businesses</a>
<a class="btn" href="/registerBusiness">Register a business</a>
}

然后我有一个 for 循环来显示所有的业务:

<ul>
@for(business <- businessList) {
<li>
<p>Business Name: @business.getName()</p>
<p>Business Type: @business.getType()</p>
<p>Business Email: @business.getEmail()</p>
<p>Business Location: @business.getLocation()</p>
<p>Business Description: @business.getDescription()</p>
<p>Id is: @business.id </p>

<a class="btn" href="@routes.Application.displayUpdateBusiness(business.id)">Update</a>
@form(routes.Application.deleteBusiness(business.id)) {
<input class="btn" type="submit" value="Delete">
}
</li>
}
</ul>

当用户提交他们的表单时,displayAllbusinesses 路由看起来像(这是错误出现的地方):

GET      /listBusinesses            controllers.Application.displayAllBusinesses(type: String ?= "all")  

app/Application.java 中的 displayAllbusinesses 方法是:

public static Result displayAllBusinesses(String type){
List<Business> businesses;
if(type=="all"){
businesses = allBusinesses;
} else {
businesses = Business.find.where().like("type", type).findList();
//TRACE
System.out.println(businesses);
}
return ok(listBusinesses.render(businesses, businessForm));
}

当我运行这段代码时,我得到了/listBusinesses 路由的“简单表达式的非法开始”。这是什么意思?

最佳答案

type 是 Scala 中的保留关键字。路由编译器没有正确转义它,我认为这是一个已知错误。

关于java - Play框架-简单表达式的非法启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18042166/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com