thymeleaf上的window.location.href

时间:2017-06-21 10:53:49

标签: javascript html html5 thymeleaf

我的Thymeleaf模板中有这段代码,但由于这是生成的位置,因此无法正常工作

deviceevent/@%7B/deviceevent/list/%7Bid%7D(id=$%7BdeviceEvent.id%7D)%7D
模板中的

<tr th:each="deviceEvent : ${deviceEvents}"  onclick="window.location.href = '@{/deviceevent/list/{id}(id=${deviceEvent.id})}'" >

1 个答案:

答案 0 :(得分:8)

Thymeleaf不评估属性,除非它们以public Callback<Items> getItemsFromApi(final RestApiListener listener) { return new Callback<Items>() { @Override public void onResponse(Call<Items> call, Response<Items> response) { switch (response.code()) { case 200: listener.onSuccess(response.body().getItems()); break; default: listener.onError("Error " + response.message()); break; } } @Override public void onFailure(Call<Items> call, Throwable t) { listener.onError(t.getMessage().toString()); } }; } public interface RestApiListener { void onSuccess(List<Items> items); void onError(String s); } 为前缀。在这种情况下,th。完整的字符串应如下所示:

th:onclick