Springboot 설정 suffix 지정 mvc 보기 접미사 방법
2793 단어 Springbootsuffix화면 음악 보기접미사
다음 과 같다.
spring:
# MVC
mvc:
view:
suffix: ".html"
지정 한 접 두 사 를 설정 한 후welcome.html 페이지 를 방문 할 때"welcome"만 쓰 면 됩 니 다.
@Controller
public class demoController {
@GetMapping("/a")
public String demo(){
return "welcome";
}
실행 결과:SpringBoot 에서 MVC-controller 가 요청 한 접미사 이름 설정
1.시작 클래스 추가 설정
package com.ias.oil.client.schedule;
import com.ias.oil.model.OILService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.DispatcherServlet;
@EnableDiscoveryClient
@EnableFeignClients({OILService.PACKAGE_FOR_SERVICE_SCHEDULE})
@SpringBootApplication
public class OILScheduleClientApplication {
public static void main(String[] args) {
SpringApplication.run(OILScheduleClientApplication.class, args);
}
/**
* .action
* @param dispatcherServlet
* @return
*/
@Bean
public ServletRegistrationBean servletRegistrationBean(DispatcherServlet dispatcherServlet) {
ServletRegistrationBean bean = new ServletRegistrationBean(dispatcherServlet);
bean.addUrlMappings("*.action");
return bean;
}
}
위 코드 세 션 의 이 부분 을 추가 해 야 합 니 다.
/**
* .action
* @param dispatcherServlet
* @return
*/
@Bean
public ServletRegistrationBean servletRegistrationBean(DispatcherServlet dispatcherServlet) {
ServletRegistrationBean bean = new ServletRegistrationBean(dispatcherServlet);
bean.addUrlMappings("*.action");
return bean;
}
2.프로필 에 프로필 추가
spring:
mvc:
## .action
pathmatch:
use-suffix-pattern: false
use-registered-suffix-pattern: true
contentnegotiation:
favor-path-extension: false
일 을 끝내다이상 은 개인 적 인 경험 이 므 로 여러분 에 게 참고 가 되 기 를 바 랍 니 다.여러분 들 도 저 희 를 많이 응원 해 주시 기 바 랍 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
[MeU] Hashtag 기능 개발➡️ 기존 Tag 테이블에 존재하지 않는 해시태그라면 Tag , tagPostMapping 테이블에 모두 추가 ➡️ 기존에 존재하는 해시태그라면, tagPostMapping 테이블에만 추가 이후에 개발할 태그 기반 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.