Contents
접기
java.lang.IllegalArgumentException : Name for argument of type [java.lang.String] not specified, and parameter name information not available via reflection. Ensure that the compiler uses the '-parameters' flag.] with root cause
해결방법
build.gradle 에 추가하기
compileJava {
options.compilerArgs << '-parameters'
}
controller 에서 @RequestParam 안에 사용할 value 값 넣어주기
@GetMapping("/write")
public String write(
@RequestParam(value="from") String from, Model model ) {
model.addAttribute("from", from);
return "/guest/write";
}
처음엔 chatgpt 를 사용하여 물어보니 @RequestParam(required = false) 을 말해주었다. 당연하게 오류가 났다.
그래서 찾아보니.. 저렇게 사용하면 된다.
사용한 이유
<div class="write"><a th:href="@{/reservation/write?from=qna}"><i class="fa-solid fa-pen-to-square"></i> 글쓰기</a></div>
들어오는 페이지를 통해 보이는 뷰 단을 다르게 하기 위해 from 부분 부터 읽어와야 하기 때문
<td th:if="${from == 'qna'}">핸드폰 번호<p>*</p></td>
<td th:if="${from == 'qna'}"><input type="text" name="" id="phone" placeholder="01012345678" required></td>
사용은 이렇게 된다.
'개인 공부 > 에러는 그만' 카테고리의 다른 글
[React] 공공데이터 API <errMsg>SERVICE ERROR</errMsg> (0) | 2024.10.31 |
---|---|
[React] Cannot read properties of undefined (reading 'prototype') (0) | 2024.10.25 |
[오라클] m1_ sqldeveloper 새 계정 생성 (0) | 2024.06.11 |
[.shp] 좌표 파일 읽기 (0) | 2024.06.01 |