如何從Thymeleaf訪問constant?public?final?static?int?SOME_CONSTANT?=?255;我正在使用以下代碼:@com.company.project.classWithConstants@SOME_CONSTANT我收到以下異常:com/company/project/classWithConstants(錯誤名稱:com/company/project/ClassWithConstants)
1 回答

幕布斯7119047
TA貢獻1794條經驗 獲得超8個贊
如您所知,Thymeleaf 使用OGNL來處理命令。所以,如果沒有 Spring 和 SpEL,這可以這樣實現:
<td> ????<input?class="form-control"?type="text"?name="inputValue" ????????th:maxlength="${@com.example.yourpackagename.Constants@MAX_TESTCASE_VALUE_LENGTH}"?/> </td>
添加回答
舉報
0/150
提交
取消