简单表达的非法开始

简单表达的非法开始

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

@(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中的保留关键字。路由编译器无法正确转义,我认为这是一个已知的错误。

07-27 18:35