반응형
250x250
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 |
Tags
- VPN
- kubeflow
- or some instances in your deployment group are experiencing problems.
- PostgreSQL
- codebuild
- chart.js
- bootstrap
- codepipeline
- SQL
- Spring
- Flux
- IntelliJ
- JavaScript
- aws cicd
- Python
- Kafka
- 도커
- COALESCE
- node
- aws
- java bigdecimal
- redis
- codedeploy
- Spring Error
- codedeploy error
- docker
- chartjs
- Jenkins
- AWS CI/CD 구축하기
- Airflow
Archives
- Today
- Total
Small Asteroid Blog
[spring boot ajax error] com/fasterxml/jackson/annotation/JsonIncludeProperties 해결방법 본문
카테고리 없음
[spring boot ajax error] com/fasterxml/jackson/annotation/JsonIncludeProperties 해결방법
작은소행성☄️ 2021. 4. 16. 14:13728x90
com/fasterxml/jackson/annotation/JsonIncludeProperties
나의경우 ajax에서 보내는 json 값과
controller에서 받는 쪽에서 타입이 맞지않아 생기는 현상이였다
ajax 보내는 쪽 코드
function formsendfunc(){
var formid = $('#formid').serializeArray(); //동적 입력된 값도 들어옴 // form name태그 필수
var obj = {};
var paramval = "";
var dataval="";
//api 이름 제외하고싶으면 i=1부터 시작하면됨
for (var i=0;i<formid.length;i++){
if(i <=2){ //servicekey값까지는 name입력
obj[formid[i]['name']] = formid[i]['value'];
}else {
if(i % 2 == 1){ //홀수일경우 파라메터 이름
paramval = formid[i]['value'];
}else{ //짝수일경우 파라메터 값
dataval = formid[i]['value'];
}
}
obj[paramval] = dataval;
}
var formjson = JSON.stringify(obj);
console.log(' formid > ',formid," obj > ",obj,', formjson> ',formjson);
//ajax 실행하면 Exception Processing ErrorPage[errorCode=0, location=/error] 에러남
//request가 알려준 content type에 맞는 response 를 생성할 수 없기 때문에 발생
$.ajax({
type : "post",
url : "/openparam2",
data : obj,
datatype:'json',
success : function(data){
console.log("success > ",data);
showapi(data);
},
error:function (xhr, status, error){
console.log(error,xhr,status);
}
});//ajax
}
에러가 발생한 코드
@RequestMapping(value="/openparam1",method = RequestMethod.POST)
@ResponseBody
public Map<String,String> openParam1(HttpServletRequest request, @RequestParam LinkedHashMap params) throws Exception {
}
해결한 코드
@RequestMapping(value="/openparam2",method = RequestMethod.POST)
@ResponseBody
public String openParam2(HttpServletRequest request, @RequestParam LinkedHashMap params) throws Exception {
}
Map<String,String> 을 String 으로 바꿔서 사용
728x90
반응형