[精讚] [會員登入]
981

[vue.js] 設定 content type

今天在wickt 端怎麼就是收不到vue.js 以post 傳過來的資料 找了好久才發現 application/jso

分享此文連結 //n.sfs.tw/10306

分享連結 [vue.js] 設定 content type @igogo
(文章歡迎轉載,務必尊重版權註明連結來源)
2016-11-26 23:21:47 最後編修
2016-11-26 23:13:52 By igogo
 

今天在wickt 端遇到怎麼就是收不到vue.js 以post 傳過來的資料

找了好久才發現 application/json 與 application/x-www-form-urlencoded 的不同

前端必須用 application/x-www-form-urlencoded 送, wicket 才收得到

Vue.http.options.emulateJSON = true;

 

ContentType 為 application/json

Vue.http.options.emulateJSON = false;

 

 

在wicket端回傳json 格式時 也要設定ContentType

   getRequestCycle().scheduleRequestHandlerAfterCurrent(new IRequestHandler() {
            @Override
            public void respond(IRequestCycle requestCycle
            ) {
                //回傳json 格式
                ((WebResponse) requestCycle.getResponse()).setContentType("application/json");
                // Add JSON-encoded string to the response.
                Response response = requestCycle.getResponse();
                response.write(returnValue);
            }

 

END

你可能感興趣的文章

Spring Boot Maven wrappers maven, mvnw, build command

ArrayList 與 HashMap 範例 public static void main(String[] args) { String titleIds = &

java lambda files filter java, files filter, lambda

Thread java thread

java.time 時間 instant java.time

停止多執行緒 利用主程式呼叫多執行緒時, 要怎麼停止正在執行的多執行緒

隨機好文

vue.js modal 作兩個選項按鈕並導向不同頁面 vue.js modal 作兩個選項按鈕

python 的RE python re

臺中市雲端校務系統與Windows AD帳號整合(4) 雲端校務系統與Windows AD的架構

在docker裡跑spring boot+mongo(一) 系統安裝docker ce centos7 + docker ce https://docs.docker.com/in

台中市網路應用競賽試場安排(一) 排試場就跟排班或是排課表一樣, 找不到一個都能讓所有人滿意的結果