1. 로그
예제) TestController.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger logger = LoggerFactory.getLogger(TestController.class);
@GetMapping("/list")
public String testList() {
logger.info("TestController, testList.");
return "test/testList";
}
2. 필터 설정
Project -> src -> main -> web.xml
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
아랫부분에 추가
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
3. @RequestMapping 편리한 방법
기존_) @RequestMapping(value = "/", method = RequestMethod.GET)
or
추가 _) @GetMapping
4. ajax
$.ajax({
type : "타입"
, url : "url"
, data : "데이터"
, contentType : "형식"
, success : "성공"
, error : "에러"
});
ex)
ajax ({
type : "put"
, url : "/test/detail/put"
, data : JSON.stringify(jsonData)
, contentType : "application/json; charset=utf-8"
, success : function(result) {
if (result == "SUCCESS") {
alert ("전송에 성공하였습니다.");
}
, error : function(error) {
alert("전송에 실패하였습니다.");
}
});
'Spring' 카테고리의 다른 글
[Spring] enum(이늄) 사용자 레벨 관리 기능 (0) | 2022.06.15 |
---|---|
[Spring] @Controller, @RestController의 차이 (0) | 2022.06.14 |
[Spring] StringUtils 예제 (0) | 2022.06.08 |
[Spring] MyBatis 적용 (0) | 2022.06.07 |
[Spring] mariadb spring datasource 적용 (0) | 2022.06.07 |