當前位置:編程學習大全網 - 網站源碼 - response.getwriter.print(boolean) 怎樣在攔截器postHandle中得到其boolean返回值

response.getwriter.print(boolean) 怎樣在攔截器postHandle中得到其boolean返回值

通過分析 response.getwriter.print(boolean) 的源代碼發現 print(boolean) 方法返回的是壹個字符串的表示形式。故 直接在postHandle中獲取字符串比較即可。

詳細源代碼如下:

/**

*?Prints?a?boolean?value.?The?string?produced?by?<code>{@link

*?java.lang.String#valueOf(boolean)}</code>?is?translated?into?bytes

*?according?to?the?platform's?default?character?encoding,?and?these?bytes

*?are?written?in?exactly?the?manner?of?the?<code>{@link

*?#write(int)}</code>?method.

*

*?@param?bThe?<code>boolean</code>?to?be?printed

*/

public?void?print(boolean?b)?{

write(b"true"?:?"false");

}

//?write?方法

/**

*?Writes?a?string.?This?method?cannot?be?inherited?from?the?Writer?class

*?because?it?must?suppress?I/O?exceptions.

*?@param?s?String?to?be?written

*/

public?void?write(String?s)?{

write(s,?0,?s.length());

}

  • 上一篇:大哥求源碼
  • 下一篇:最近在旅遊圈很紅的胖叔是什麽來歷?
  • copyright 2024編程學習大全網