[精讚] [會員登入]
1215

[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

你可能感興趣的文章

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

Spring Boot Maven wrappers maven, mvnw, build command

java.time 時間 instant java.time

spring boot jpa 使用多個欄位排序 我有一entity 叫 team 資料欄下如下 @Id @GeneratedValue(strategy = Gener

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

spring boot 使用jdbc連接mariadb spring boot, mariadb, jdbc, rowmapper

隨機好文

雲端校務系統與OPENLDAP帳號整合(2) openldap,雲端校務

在docker裡跑spring boot+mongo(二) 使用docker-compose 管理多個container 前篇使用docker run 一次建一個container

scratch 不重覆隨機取陣列值 隨機取數是在設計遊戲時, 很常用到的技巧 最簡單的就是使用運算積木裡的隨機取數範圍 但是, 如果我是想全部取出且不重覆,

網站無障礙規範 https://accessibility.ncc.gov.tw/News/Detail/3238?Category=4

用java讀取microbit寫到serial的資料 用java讀取microbit寫到serial的資料