Struts2 0中Action直接返回字串

2021-08-31 05:16:09 字數 509 閱讀 5034

對於struts2中action中返回字串的處理,比如做級聯時,就可能用到返回json(字串)的資料,些時action該返回字串,其實:讓action中的返回字串的方法,直接return null;並在return之前用輸出流輸出字串就可以了,跟servlet輸入html方法一樣。

1、

public class cscandmsaction extends actionsupport implements servletresponseaware

/** * country dms做級聯時返回的json資料(字串)

* @param numcountryguid

* @return

*/public string gettestjson() throws exception catch (ioexception e)

"utf-8");

pw.flush();

pw.close();

return null;

}}

Struts2 0中Action直接返回字串

json servlet html 對於struts2中action中返回字串的處理,比如做級聯時,就可能用到返回json 字串 的資料,些時action該返回字串,其實 讓action中的返回字串的方法,直接return null 並在return之前用輸出流輸出字串就可以了,跟servlet輸入...

Struts2 0中Action直接返回字串

部落格分類 struts json servlet html 對於struts2中action中返回字串的處理,比如做級聯時,就可能用到返回json 字串 的資料,些時action該返回字串,其實 讓action中的返回字串的方法,直接return null 並在return之前用輸出流輸出字串就可...

struts2 0 的action標籤使用

使用action標籤可 以允許在jsp頁面中直接呼叫action,因為需要呼叫action,故可以指定需要被呼叫action的name以及namespace。如果指定 了executeresult引數的屬性值為true,該標籤還會把action的處理結果 檢視支援 包含到本頁面中來。action標籤...