paramutils.java
来自「J2EE网络书店系统 采用JSP , servlet ,javabean开发 」· Java 代码 · 共 90 行
JAVA
90 行
/*
* 创建日期 2005-3-7
*
* TODO 要更改此生成的文件的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
package store;
/**
* @author wwx
*
* TODO 要更改此生成的类型注释的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
import javax.servlet.http.HttpServletRequest;
public class ParamUtils {
public ParamUtils()
{
}
private static String getString(HttpServletRequest httpservletrequest, String s)
{
String s1 = null;
try
{
s1 = httpservletrequest.getParameter(s).trim();
}
catch(Exception exception) { }
return s1;
}
public static String getString(HttpServletRequest httpservletrequest, String s, String s1)
throws Exception
{
String s2 = getString(httpservletrequest, s);
if(s2 == null)
return s1;
else
return s2;
}
public static int getInt(HttpServletRequest httpservletrequest, String s, int i)
{
String s1 = getString(httpservletrequest, s);
if(s1 == null)
return i;
try
{
return Integer.parseInt(s1);
}catch(NumberFormatException numberformatexception)
{
return 0;
}
}
public static long getLong(HttpServletRequest httpservletrequest, String s, long l)
{
String s1 = getString(httpservletrequest, s);
if(s1 == null)
return l;
try
{
return Long.parseLong(s1);
}catch
(NumberFormatException numberformatexception)
{
return 0L;
}
}
public static String getallstring(HttpServletRequest httpservletrequest, String s)
{
String s1 = "";
try
{
String as[] = httpservletrequest.getParameterValues(s);
if(as == null)
throw new Exception("Not any value was selected!<br>");
for(int i = 0; i < as.length; i++)
s1 = s1 + as[i];
}
catch(Exception exception) { }
return s1;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?