\#springMessage 오류 분석
$springMacroRequestContext.getMessage($code)
#springMessage org/spring from work/web/servlet/view/velocity/spring.vm 파일 에서 매크로 를 정의 합 니 다.그 내용 은:
#**
* springMessage
*
* Macro to translate a message code into a message.
*#
#macro( springMessage $code )$springMacroRequestContext.getMessage($code)#end
springMacroRequestContext 또 뭐 죠?
분석 봄 의 코드 를 발견 할 수 있 습 니 다:
이것 은 AbastractTemplate View 에서 북쪽 으로 정 의 된 값 입 니 다.
public abstract class AbstractTemplateView extends AbstractUrlBasedView {
/**
* Variable name of the RequestContext instance in the template model,
* available to Spring's macros: e.g. for creating BindStatus objects.
*/
public static final String SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE = "springMacroRequestContext";
if (this.exposeSpringMacroHelpers) {
if (model.containsKey(SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE)) {
throw new ServletException(
"Cannot expose bind macro helper '" + SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE +
"' because of an existing model object of the same name");
}
// Expose RequestContext instance for Spring macros.
model.put(SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE,
new RequestContext(request, response, getServletContext(), model));
}
이로써 우 리 는 발견 할 수 있다 이 대상 은 org.springframework.web.servlet.support.RequestContext 입 니 다. 대상
최종 호출 된 방법 은:
/**
* Retrieve the message for the given code, using the "defaultHtmlEscape" setting.
* @param code code of the message
* @return the message
* @throws org.springframework.context.NoSuchMessageException if not found
*/
public String getMessage(String code) throws NoSuchMessageException {
return getMessage(code, null, isDefaultHtmlEscape());
}
그러나 최종 적 으로 페이지 에 표 시 된 것 은:
$springMacroRequestContext.getMessage($code)
이 출력 을 통 해 이 매크로 가 정의 되 지 않 았 기 때 문 임 을 알 수 있 습 니 다. 왜 정의 되 지 않 았 는 지 자세히 생각해 보 세 요.이상 할 때 들 어 오 는 code 입 니 다. String 이 아니에요. 유형
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
thymeleaf로 HTML 페이지를 동적으로 만듭니다 (spring + gradle)지난번에는 에서 화면에 HTML을 표시했습니다. 이번에는 화면을 동적으로 움직여보고 싶기 때문에 입력한 문자를 화면에 표시시키고 싶습니다. 초보자의 비망록이므로 이상한 점 등 있으면 지적 받을 수 있으면 기쁩니다! ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.