我是玩框架的新手。在尝试使用播放生成html模板时,我在 ticket.getTicketIds 行收到错误非法启动简单模式。已经花了一些时间试图解决这个问题,但没有好处。
<tbody>
@for( ticket <- @obj.getPurchasedTickets() ) {
@for( (key,val) <- @obj.getTicketsCalculation() ) {
@if( key.equals(ticket.getTicketId())) {
<tr>
<td class="desc">@ticket.getTicketName()<br></br>
@if(ticket.getTicketIds() != null && !ticket.getTicketIds().isEmpty()) {
@for( ticketid <- ticket.getTicketIds ){
#@ticketid
}
}
</td>
<td class="unit">@ticket.getPrice()</td>
</tr>
}
}
}
</tbody>
以下POJO用于获取必要的值
public class PurchasedTicket {
private String ticketId; // represents the ticket's id
private String ticketName;
private Integer numberOfTickets;
private Double price;
private List<String> ticketIds; // list of tickets bought with this ticket
// setters and getters
}
public class Wrapper{
private Map ticketsCalculation;
private List<PurchasedTicket> purchasedTickets;
// setters and getters
}
模板部分中表示的obj是 Wrapper 类的对象
答案 0 :(得分:1)
只是为了编译:
如上所述@ rouge-one,您可以使用不同的变量名称,例如。值。
您不应使用多个@
标志。正如docs所述,它应该在动态语句的开头使用,例如。 @for( ticket <- obj.getPurchasedTickets() ) {
所以工作代码应如下所示:
<tbody>
@for(ticket <- obj.getPurchasedTickets()) {
@for((key, value) <- obj.getTicketsCalculation()) {
@if(key.equals(ticket.getTicketId())) {
<tr>
<td class="desc">@ticket.getTicketName()<br></br>
@if(ticket.getTicketIds() != null && !ticket.getTicketIds().isEmpty()) {
@for(ticketid <- ticket.getTicketIds){
#@ticketid
}
}
</td>
<td class="unit">@ticket.getPrice()</td>
</tr>
}
}
}
</tbody>
答案 1 :(得分:0)
将模板第3行中的属性名称从#!/usr/bin/env python
from pyvirtualdisplay import Display
from selenium import webdriver
import os
os.environ['DISPLAY'] = ':100'
display = Display(visible=0, size=(800, 600))
display.start()
browser = webdriver.Firefox()
browser.get('http://www.test.com')
browser.quit()
display.stop()
更改为val
,因为value
是保留字。
val
例如见下文
(key,value) <- @obj.getTicketsCalculation()
阶&GT; val(key,value)=“key1” - &gt; “VAL1” key:String = key1 value:String = val1
scala> val (key, value) = "key1" -> "val1"
key: String = key1
value: String = val1