public class MapImageServlet extends HttpServlet {//... constructor and other methods ...protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // OPTIonAL PARAMETERS boarderSize = ParamUtil.getDoublevalue(request,"boarderSize", defaultValue); boarderThickness = ParamUtil.getDoublevalue(request, "boarderThickness", defaultValue); boarderColor = ParamUtil.getDoublevalue(request,"boarderColor" , defaultValue); //... do stuff with the parameters ...}}public class ParamUtil{public static double getDoublevalue(ServletRequest request, String paramName, double defaultValue){ if(request.getParameter(paramName) != null){ return Double.valueOf(request.getParameter(paramName)); } else{ return defaultValue; }}}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)