[精讚] [會員登入]
944

[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

你可能感興趣的文章

java lambda files filter java, files filter, lambda

Arrays.asList 後想再add出現 UnsupportedOperationException 這個問題真是搞死我了 List<String> fruits = Arrays.asList("a

讀取特定資料夾下的xls檔 讀取特定資料夾下的xls檔

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

java-身份証字號驗証 FormatCheck.java public class FormatCheck { private volatile

keycloak 透過java client lib新增user 使用keycloak-admin-client lib maven <dependency> <gro

隨機好文

[vue.js] input event Form-Input-Components-using-Custom-Events

axios vuejs application/x-www-form-urlencoded 送資料 VUE.JS 以 application/x-www-form-urlencoded 送資料

proxmox lxc 救援 今天突然接到一名強者我朋友的臨時求援 他說他把pve 從5.1升到5.2後, kvm的虛擬机器都沒問題 , 但是lxc的

vim 特定範圍行數開頭加上# 註解 vim 特定範圍行數開頭加上# 註解

ubuntu ufw ufw 簡易筆記 原則禁止,例外開放 ufw default deny 啟動ufw sudo ufw enable 關掉