我试图在单击某个功能的按钮时发送参数。但是,出现以下错误:
app / views / index.scala.html:44:84:找不到:值postid [错误]
index.scala.html:
<section class="search-sec">
<div class="container">
<form action="window.location.href='@routes.AppController.retrieveByFields(postid, text_filter)';" method="get" novalidate="novalidate">
<div class="row">
<div class="col-lg-12">
<div class="row">
<div class="col-lg-3 col-md-3 col-sm-12 p-0">
<input type="text" id="postid" name = "postid" class="form-control search-slt" placeholder="Enter Post Id" required>
</div>
<div class="col-lg-3 col-md-3 col-sm-12 p-0">
<input type="text" id= "text_filter" name="text_filter" class="form-control search-slt" placeholder="Enter text to search">
</div>
<div class="col-lg-3 col-md-3 col-sm-12 p-0">
<input type="submit" button type="button" class="btn btn-danger wrn-btn">Search</button>
</div>
</div>
</div>
</div>
</form>
</div>
</section>
路线
GET /comments/:id controllers.AppController.retrieveByFields(id: Int, text: java.util.Optional[String])
控制器功能
public Result retrieveByFields(int postid, java.util.Optional<String> text) throws IOException, ParseException
我在做什么错? 谢谢您的帮助。
答案 0 :(得分:0)
在您的视图文件中,它不知道您的postid
是什么。两件事: