fix: html viewresolver 오류 fix

dev
gitea-관리자 1 year ago
parent 1bd613db4b
commit 714c6c5366

@ -14,7 +14,6 @@ import kr.xit.core.spring.config.auth.AuthentificationInterceptor;
import kr.xit.core.spring.config.properties.CorsProperties;
import kr.xit.core.spring.filter.LoggingFilter;
import kr.xit.core.spring.filter.ReadableRequestWrapperFilter;
import kr.xit.core.spring.resolver.JsonPathArgumentResolver;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
@ -29,7 +28,6 @@ import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConve
import org.springframework.web.filter.CommonsRequestLoggingFilter;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@ -59,7 +57,6 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
*/
@RequiredArgsConstructor
@Configuration
@EnableWebMvc
public class WebMvcConfig implements WebMvcConfigurer {
/**
* logging exclude path
@ -182,7 +179,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
//TODO :: ArgumentResolver add
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
resolvers.add(new JsonPathArgumentResolver());
// resolvers.add(new CustomArgumentResolver());
// resolvers.add(new PageableArgumentResolver());
}

@ -0,0 +1,37 @@
package kr.xit.core.spring.resolver;
import java.util.Locale;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.view.AbstractUrlBasedView;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
/**
* <pre>
* description : "html/" HtmlViewResolver . null
* packageName : kr.xit.core.spring.resolver
* fileName : HtmlViewResolver
* author : julim
* date : 2023-10-04
* ======================================================================
*
* ----------------------------------------------------------------------
* 2023-10-04 julim
*
* </pre>
*/
public class HtmlViewResolver extends InternalResourceViewResolver {
@Override
protected View loadView(String viewName, Locale locale) throws Exception {
AbstractUrlBasedView view = buildView(viewName);
View viewObj = (View) getApplicationContext().getAutowireCapableBeanFactory().initializeBean(view, viewName);
if (viewObj instanceof JstlView) {
JstlView jv = (JstlView) viewObj;
if (jv.getBeanName().indexOf(".html") == -1) {
return null;
}
}
return viewObj;
}
}

@ -0,0 +1,38 @@
package kr.xit.core.spring.resolver;
import java.util.Locale;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.view.AbstractUrlBasedView;
import org.springframework.web.servlet.view.JstlView;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
/**
* <pre>
* description : "jsp/" JspViewResolver . null
* packageName : kr.xit.core.spring.resolver
* fileName : JspViewResolver
* author : julim
* date : 2023-10-04
* ======================================================================
*
* ----------------------------------------------------------------------
* 2023-10-04 julim
*
* </pre>
*/
public class JspViewResolver extends InternalResourceViewResolver {
@Override
protected View loadView(String viewName, Locale locale) throws Exception {
AbstractUrlBasedView view = buildView(viewName);
View viewObj = (View) getApplicationContext().getAutowireCapableBeanFactory().initializeBean(view, viewName);
if (viewObj instanceof JstlView) {
JstlView jv = (JstlView) viewObj;
if (jv.getBeanName().indexOf(".jsp") == -1) {
return null;
}
}
return viewObj;
}
}
Loading…
Cancel
Save