일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- 배열
- push함수
- Node.js
- int와 integer
- dart
- Oracle
- 추상클래스
- app.use
- Middleware
- 삼항연산자
- Sort()
- git
- 자바스크립트
- React
- 콘솔게임
- js
- 다형성
- java
- mybatis
- 자바
- 네임드생성자
- Spring
- DB
- 생성자
- 오류
- qqOperater
- Pug
- 리액트
- 깃허브
- 코딩테스트
- Today
- Total
평행코드
ResponseEntity/ WebMvcConfigurer Interface / application.properties 본문
ResponseEntity/ WebMvcConfigurer Interface / application.properties
나의 오류는 누군가 겪었던 오류 2023. 12. 20. 09:04🔆ResponseEntity
응답헤더와 바디를 제공
Spring Framework에서 제공하는 클래스 중 HttpEntity라는 클래스가 존재한다.
이것은 HTTP 요청(Request) 또는 응답(Response)에 해당하는 HttpHeader와 HttpBody를 포함하는 클래스이다.
🔆HttpEntity 클래스를 상속받아 구현한 클래스가 RequestEntity, ResponseEntity 클래스이다.
ResponseEntity는 사용자의 HttpRequest에 대한 응답 데이터를 포함하는 클래스이다.
따라서 HttpStatus, HttpHeaders, HttpBody를 포함한다.
🔆fetch("${pageContext.request.contextPath}")
나중에 프로젝트올렸을때 경로를 못찾을 수 있기때문에 contextPath설정꼭하기
🔆WebMvcConfigurer
// xml파일대신 이제 여기에서 등록해주기! // 환경설정에대한것 @Configuration //WebMvcConfigurer 인터페이스사용 @Configuration //Configuration으로 환경설정하기
public class WebMVCConfiguration implements WebMvcConfigurer{
@Override
public void addInterceptors(InterceptorRegistry registry) {
// 인터셉터등록할때 사용하는 메소드
registry.addInterceptor(loggerInterceptor())
.addPathPatterns("/**");
}
@Override
// addViewControllers 이 주소로 오면 이거연결해!
public void addViewControllers(ViewControllerRegistry registry) {
// view연결해주는 로직을 코드로 작성할때 사용
registry.addViewController("/board/boardlist").setViewName("board/boardlist");
// 컨트롤러에 굳이 선언안하고 config 파일에 설정할 수 있음! 작성하는 방식이 다를뿐 모든 view를 여기서 작성하진 않는다.
}
// bean으로 등록해서 관리할 수 있음
@Bean
LoggerInterceptor loggerInterceptor() {
return new LoggerInterceptor();
}
@Bean
Member member() {
return new Member();
}
}
application.propertie 파일
#서버start시간 증가시키기 #server.tomcat.connection-timeout=18000000
🔆Database 설정하기
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver spring.datasource.url=jdbc:oracle:thin:@localhost:1521:xe spring.datasource.username=spring spring.datasource.password=spring
🔆mybatis설정하기
mybatis.config-location=classpath:/config/mybatis-config.xml mybatis.mapper-locations=classpath:/mappers/**/*.xml
🔆jsp설정하기 -> Internal View Resolver등록하기 (뷰 정보 설정)
spring.mvc.view.prefix=/WEB-INF/views/ spring.mvc.view.suffix=.jsp
🔆로그설정변경하기
logging.level.[com.bs.firstboot]=debug #com.bs.firstboot 이패키지에 해당하는 애들은 debug를 출력해줘
'Spring' 카테고리의 다른 글
Spring boot (0) | 2023.12.19 |
---|---|
<Spring> Security (0) | 2023.12.14 |
<Spring> AOP (Aspect Orientied Programing) (0) | 2023.12.13 |
<Spring> 트랜잭션처리하기 (0) | 2023.12.13 |
<Spring> 인터셉터(Interceptor) (0) | 2023.12.11 |