?? requestparameter.java
字號:
package kmd.commo;import javax.servlet.http.HttpServletRequest;/** 頁面參數 * <p>Title:</p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2007</p> * <p>Company: 重慶科美達電腦有限公司</p> * @author * @version 1.0 */public class RequestParameter { private HttpServletRequest request = null; public RequestParameter(HttpServletRequest _request) { request = _request; } public long getLong(String name, long defaultvalue) { try { String value = request.getParameter(name); return Long.parseLong(value); } catch (Exception ex) {} return defaultvalue; } public long getLong(String name) throws Exception { try { String value = request.getParameter(name); return Long.parseLong(value); } catch (Exception ex) { throw new Exception(ex.getMessage()); } } public float getFloat(String name, long defaultvalue) { try { String value = request.getParameter(name); return Float.parseFloat(value); } catch (Exception ex) {} return defaultvalue; } public float getFloat(String name) throws Exception { try { String value = request.getParameter(name); return Float.parseFloat(value); } catch (Exception ex) { throw new Exception(ex.getMessage()); } } public String getString(String name, String defaultvalue) { String value = request.getParameter(name); if (value != null) { return value; } return defaultvalue; } public String getString(String name) throws Exception { String value = request.getParameter(name); if (value != null) { return value; } throw new Exception("參數不存在"); } public int getInt(String name, int defaultvalue) { try { String value = request.getParameter(name); return Integer.parseInt(value); } catch (Exception ex) {} return defaultvalue; } public int getInt(String name) throws Exception { try { String value = request.getParameter(name); return Integer.parseInt(value); } catch (Exception ex) { throw new Exception(ex.getMessage()); } } public java.sql.Date getDate(String name, java.sql.Date defaultvalue) { try { String value = request.getParameter(name); return java.sql.Date.valueOf(value); } catch (Exception ex) {} return defaultvalue; } public java.sql.Date getDate(String name) throws Exception { try { String value = request.getParameter(name); return java.sql.Date.valueOf(value); } catch (Exception ex) { throw new Exception(ex.getMessage()); } }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -