내가 추가 할 선택한 HTML 태그에 옵션 RequestParam의 상태를 확인하여 동적으로 Thymeleaf를 사용하여 :
<option value="en" th:text="${#httpServletRequest.getParameter('lang') == null || #httpServletRequest.getParameter('lang') == 'en'} ? #{lang.eng}"></option>
<option value="ru" th:text="#{lang.ru}" th:attr="${#httpServletRequest.getParameter('lang') == 'ru'} ? 'selected' : null"></option>
하지만 두 번째 옵션에 오류가 있습니다.
다른 언어로 전환 할 때 선택한 언어가 변경되지 않기 때문에 그렇게하는 이유는이 문제를 어떻게 해결할 수 있습니까? 아니면 다른 접근 방식을 사용해야합니까?
selected
속성 과 함께 고정 값 부울 속성을 참조해야 합니다.
대신에
th:attr="${#httpServletRequest.getParameter('lang') == 'ru'} ? 'selected' : null"
넌 할 수있어:
th:selected="${#httpServletRequest.getParameter('lang') == 'ru'}"
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다