Có lỗi xảy ra trong quá trình xử lý biểu mẫu.
Denied access to method or field getParameter of class org.apache.catalina.core.ApplicationHttpRequest
----
FTL stack trace ("~" means nesting-related):
- Failed at: #assign selectedCategoryIdFromUrl = r... [in template "29795641980326#20120#562861" at line 2, column 1]
----
1<#-- ID chuyên mục đang chọn từ URL (nếu có) -->
2<#assign selectedCategoryIdFromUrl = request.getParameter("categoryId")!"" />
3
4<select id="categoryDropdown">
5 <option value="">-- Chọn chuyên mục --</option>
6 <#if entries?has_content>
7 <#-- Lấy danh sách chuyên mục từ entries -->
8 <#assign categoryMap = {} />
9 <#list entries as entry>
10 <#list entry.getCategories() as cat>
11 <#-- Tránh trùng lặp category -->
12 <#if !categoryMap?keys?seq_contains(cat.getCategoryId()?string)>
13 <#assign categoryMap = categoryMap + { (cat.getCategoryId()?string) : cat.getTitle(locale) } />
14 </#if>
15 </#list>
16 </#list>
17
18 <#-- Render dropdown categories -->
19 <#list categoryMap?keys as catId>
20 <option value="${catId}"
21 <#if catId == selectedCategoryIdFromUrl>selected</#if>>
22 ${categoryMap[catId]}
23 </option>
24 </#list>
25 <#else>
26 <option value="" disabled>Không có chuyên mục nào</option>
27 </#if>
28</select>
29
30<script>
31document.addEventListener("DOMContentLoaded", function () {
32 const categoryDropdown = document.getElementById("categoryDropdown");
33 if (!categoryDropdown) return;
34
35 categoryDropdown.addEventListener("change", function () {
36 const selectedCategoryId = this.value;
37 if (selectedCategoryId) {
38 const url = new URL(window.location.href);
39 url.searchParams.set('categoryId', selectedCategoryId);
40 window.location.href = url.toString();
41 }
42 });
43});
44</script>