Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 | 31 |
Tags
- 매일프로그래밍
- oracle
- spring
- jQuery
- 조인
- 생년
- Flyweight Pattern
- SSL설정
- JavaScript
- map
- 널체크
- 분(minute)
- 알고리즘
- json
- 자바
- 병합정렬
- 자바스크립트
- 시간더하기
- boot
- SpringBoot
- ThreeWayPartition
- 스트레티지패턴
- 곱 최대값
- 파사드패턴
- java
- list
- 시(hour)
- 초(second)
- degien pattern
- 디자인패턴
Archives
- Today
- Total
만들어가는 세상
[SPRING] 406 ERROR 발생시 대처 방법 본문
[SPRING] 406 ERROR 발생시 대처 방법
step1 pom.xml 에서 dependencies 합니다.
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.7</version>
</dependency>
contentType 설정
$.ajax({
type: 'POST',
url: vewMoreVar.apiUrl,
contentType: 'application/json;charset=utf-8',
data: JSON.stringify(dataObj),
dataType: 'json',
cache: false,
async: false,
success: function(result) {
console.log(result);
},
error: function(request, status, error) {
console.log("code:" + request.status + "\n" + "message:" + request.responseText + "\n" + "error:" + error);
}
});
dispatcher-servlet.xml 설정
<bean id="templateResolver" class="org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver">
<property name="prefix" value="/WEB-INF/templates/" />
<property name="suffix" value=".html" />
<property name="templateMode" value="HTML" />
<property name="cacheable" value="false" />
</bean>
<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
<property name="favorPathExtension" value="true" />
<property name="ignoreAcceptHeader" value="true" />
<property name="useJaf" value="false" />
<property name="defaultContentType" value="text/html" />
<property name="mediaTypes">
<map>
<entry key="html" value="text/html" />
<entry key="json" value="application/json" />
</map>
</property>
</bean>
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="contentNegotiationManager" ref="contentNegotiationManager" />
<property name="viewResolvers">
<list>
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver">
<property name="order" value="1"></property>
</bean>
<ref bean="thymeleafView" />
</list>
</property>
<property name="defaultViews">
<list>
<bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView" />
</list>
</property>
</bean>
TEST.JAVA
@RequestMapping(value = "/more/directory/list", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public List<Map<String, Object>> moreDirectoryList(@RequestBody ViewMore viewMore) throws Exception {
Map<String, Object> params = dictionaryController.getCategoryCode(viewMore.getCode());
Paging paging = new Paging(viewMore.getPage(), PAGE_SIZE.DEFAULT);
return dictionaryService.getDirectoryList(params, paging);
}
'IT > SPRING' 카테고리의 다른 글
[SPRINGBOOT] SSL 적용#1 (0) | 2020.04.22 |
---|---|
[SPRINGBOOT] SPRING BOOT&GRADLE Twitter Search, Oracle 등 관리 로직입니다. (0) | 2019.11.12 |
[SPRINGBOOT] SPRING BOOT &GRADLE Google SMTP EMAIL 서버 전송 로직입니다. (0) | 2019.11.08 |
[SPRING] @RequestMapping 활용하기 (0) | 2019.11.08 |
[SPRING] REST FULL API 구현시 자주 사용되는 @RequestBody와 @ResponseBody 개념 (0) | 2019.11.08 |
Comments