liferay笑傲江湖-API之参数的工具类(ParamUtil)

 public class ParamUtil {
036    
037            public static boolean get(
038                    HttpServletRequest request, String param, boolean defaultValue) {
039    
040                    return GetterUtil.get(request.getParameter(param), defaultValue);
041            }
042    
043            public static Date get(
044                    HttpServletRequest request, String param, DateFormat dateFormat,
045                    Date defaultValue) {
046    
047                    return GetterUtil.get(
048                            request.getParameter(param), dateFormat, defaultValue);
049            }
050    
051            public static double get(
052                    HttpServletRequest request, String param, double defaultValue) {
053    
054                    return GetterUtil.get(request.getParameter(param), defaultValue);
055            }
056    
057            public static float get(
058                    HttpServletRequest request, String param, float defaultValue) {
059    
060                    return GetterUtil.get(request.getParameter(param), defaultValue);
061            }
062    
063            public static int get(
064                    HttpServletRequest request, String param, int defaultValue) {
065    
066                    return GetterUtil.get(request.getParameter(param), defaultValue);
067            }
068    
069            public static long get(
070                    HttpServletRequest request, String param, long defaultValue) {
071    
072                    return GetterUtil.get(request.getParameter(param), defaultValue);
073            }
074    
075            public static short get(
076                    HttpServletRequest request, String param, short defaultValue) {
077    
078                    return GetterUtil.get(request.getParameter(param), defaultValue);
079            }
080    
081            public static String get(
082                    HttpServletRequest request, String param, String defaultValue) {
083    
084                    String returnValue =
085                            GetterUtil.get(request.getParameter(param), defaultValue);
086    
087                    if (returnValue != null) {
088                            return returnValue.trim();
089                    }
090    
091                    return null;
092            }
093    
094            public static boolean get(
095                    PortletRequest portletRequest, String param, boolean defaultValue) {
096    
097                    return GetterUtil.get(portletRequest.getParameter(param), defaultValue);
098            }
099    
100            public static Date get(
101                    PortletRequest portletRequest, String param, DateFormat dateFormat,
102                    Date defaultValue) {
103    
104                    return GetterUtil.get(
105                            portletRequest.getParameter(param), dateFormat, defaultValue);
106            }
107    
108            public static double get(
109                    PortletRequest portletRequest, String param, double defaultValue) {
110    
111                    return GetterUtil.get(portletRequest.getParameter(param), defaultValue);
112            }
113    
114            public static float get(
115                    PortletRequest portletRequest, String param, float defaultValue) {
116    
117                    return GetterUtil.get(portletRequest.getParameter(param), defaultValue);
118            }
119    
120            public static int get(
121                    PortletRequest portletRequest, String param, int defaultValue) {
122    
123                    return GetterUtil.get(portletRequest.getParameter(param), defaultValue);
124            }
125    
126            public static long get(
127                    PortletRequest portletRequest, String param, long defaultValue) {
128    
129                    return GetterUtil.get(portletRequest.getParameter(param), defaultValue);
130            }
131    
132            public static short get(
133                    PortletRequest portletRequest, String param, short defaultValue) {
134    
135                    return GetterUtil.get(portletRequest.getParameter(param), defaultValue);
136            }
137    
138            public static String get(
139                    PortletRequest portletRequest, String param, String defaultValue) {
140    
141                    String returnValue =
142                            GetterUtil.get(portletRequest.getParameter(param), defaultValue);
143    
144                    if (returnValue != null) {
145                            return returnValue.trim();
146                    }
147    
148                    return null;
149            }
150    
151            public static boolean get(
152                    ServiceContext serviceContext, String param, boolean defaultValue) {
153    
154                    return GetterUtil.get(serviceContext.getAttribute(param), defaultValue);
155            }
156    
157            public static Date get(
158                    ServiceContext serviceContext, String param, DateFormat dateFormat,
159                    Date defaultValue) {
160    
161                    return GetterUtil.get(
162                            serviceContext.getAttribute(param), dateFormat, defaultValue);
163            }
164    
165            public static double get(
166                    ServiceContext serviceContext, String param, double defaultValue) {
167    
168                    return GetterUtil.get(serviceContext.getAttribute(param), defaultValue);
169            }
170    
171            public static float get(
172                    ServiceContext serviceContext, String param, float defaultValue) {
173    
174                    return GetterUtil.get(serviceContext.getAttribute(param), defaultValue);
175            }
176    
177            public static int get(
178                    ServiceContext serviceContext, String param, int defaultValue) {
179    
180                    return GetterUtil.get(serviceContext.getAttribute(param), defaultValue);
181            }
182    
183            public static long get(
184                    ServiceContext serviceContext, String param, long defaultValue) {
185    
186                    return GetterUtil.get(serviceContext.getAttribute(param), defaultValue);
187            }
188    
189            public static short get(
190                    ServiceContext serviceContext, String param, short defaultValue) {
191    
192                    return GetterUtil.get(serviceContext.getAttribute(param), defaultValue);
193            }
194    
195            public static String get(
196                    ServiceContext serviceContext, String param, String defaultValue) {
197    
198                    String returnValue =
199                            GetterUtil.get(serviceContext.getAttribute(param), defaultValue);
200    
201                    if (returnValue != null) {
202                            return returnValue.trim();
203                    }
204    
205                    return null;
206            }
207    
208            public static boolean getBoolean(HttpServletRequest request, String param) {
209                    return GetterUtil.getBoolean(request.getParameter(param));
210            }
211    
212            public static boolean getBoolean(
213                    HttpServletRequest request, String param, boolean defaultValue) {
214    
215                    return get(request, param, defaultValue);
216            }
217    
218            public static boolean getBoolean(
219                    PortletRequest portletRequest, String param) {
220    
221                    return GetterUtil.getBoolean(portletRequest.getParameter(param));
222            }
223    
224            public static boolean getBoolean(
225                    PortletRequest portletRequest, String param, boolean defaultValue) {
226    
227                    return get(portletRequest, param, defaultValue);
228            }
229    
230            public static boolean getBoolean(
231                    ServiceContext serviceContext, String param) {
232    
233                    return GetterUtil.getBoolean(serviceContext.getAttribute(param));
234            }
235    
236            public static boolean getBoolean(
237                    ServiceContext serviceContext, String param, boolean defaultValue) {
238    
239                    return get(serviceContext, param, defaultValue);
240            }
241    
242            public static boolean[] getBooleanValues(
243                    HttpServletRequest request, String param) {
244    
245                    return getBooleanValues(request, param, new boolean[0]);
246            }
247    
248            public static boolean[] getBooleanValues(
249                    HttpServletRequest request, String param, boolean[] defaultValue) {
250    
251                    return GetterUtil.getBooleanValues(
252                            request.getParameterValues(param), defaultValue);
253            }
254    
255            public static boolean[] getBooleanValues(
256                    PortletRequest portletRequest, String param) {
257    
258                    return getBooleanValues(portletRequest, param, new boolean[0]);
259            }
260    
261            public static boolean[] getBooleanValues(
262                    PortletRequest portletRequest, String param, boolean[] defaultValue) {
263    
264                    return GetterUtil.getBooleanValues(
265                            portletRequest.getParameterValues(param), defaultValue);
266            }
267    
268            public static boolean[] getBooleanValues(
269                    ServiceContext serviceContext, String param) {
270    
271                    return getBooleanValues(serviceContext, param, new boolean[0]);
272            }
273    
274            public static boolean[] getBooleanValues(
275                    ServiceContext serviceContext, String param, boolean[] defaultValue) {
276    
277                    return GetterUtil.getBooleanValues(
278                            serviceContext.getAttribute(param), defaultValue);
279            }
280    
281            public static Date getDate(
282                    HttpServletRequest request, String param, DateFormat dateFormat) {
283    
284                    return GetterUtil.getDate(request.getParameter(param), dateFormat);
285            }
286    
287            public static Date getDate(
288                    HttpServletRequest request, String param, DateFormat dateFormat,
289                    Date defaultValue) {
290    
291                    return get(request, param, dateFormat, defaultValue);
292            }
293    
294            public static Date getDate(
295                    PortletRequest portletRequest, String param, DateFormat dateFormat) {
296    
297                    return GetterUtil.getDate(
298                            portletRequest.getParameter(param), dateFormat);
299            }
300    
301            public static Date getDate(
302                    PortletRequest portletRequest, String param, DateFormat dateFormat,
303                    Date defaultValue) {
304    
305                    return get(portletRequest, param, dateFormat, defaultValue);
306            }
307    
308            public static Date getDate(
309                    ServiceContext serviceContext, String param, DateFormat dateFormat) {
310    
311                    return GetterUtil.getDate(
312                            serviceContext.getAttribute(param), dateFormat);
313            }
314    
315            public static Date getDate(
316                    ServiceContext serviceContext, String param, DateFormat dateFormat,
317                    Date defaultValue) {
318    
319                    return get(serviceContext, param, dateFormat, defaultValue);
320            }
321    
322            public static Date[] getDateValues(
323                    HttpServletRequest request, String param, DateFormat dateFormat) {
324    
325                    return getDateValues(request, param, dateFormat, new Date[0]);
326            }
327    
328            public static Date[] getDateValues(
329                    HttpServletRequest request, String param, DateFormat dateFormat,
330                    Date[] defaultValue) {
331    
332                    return GetterUtil.getDateValues(
333                            request.getParameterValues(param), dateFormat, defaultValue);
334            }
335    
336            public static Date[] getDateValues(
337                    PortletRequest portletRequest, String param, DateFormat dateFormat) {
338    
339                    return getDateValues(portletRequest, param, dateFormat, new Date[0]);
340            }
341    
342            public static Date[] getDateValues(
343                    PortletRequest portletRequest, String param, DateFormat dateFormat,
344                    Date[] defaultValue) {
345    
346                    return GetterUtil.getDateValues(
347                            portletRequest.getParameterValues(param), dateFormat, defaultValue);
348            }
349    
350            public static Date[] getDateValues(
351                    ServiceContext serviceContext, String param, DateFormat dateFormat) {
352    
353                    return getDateValues(serviceContext, param, dateFormat, new Date[0]);
354            }
355    
356            public static Date[] getDateValues(
357                    ServiceContext serviceContext, String param, DateFormat dateFormat,
358                    Date[] defaultValue) {
359    
360                    return GetterUtil.getDateValues(
361                            serviceContext.getAttribute(param), dateFormat, defaultValue);
362            }
363    
364            public static double getDouble(HttpServletRequest request, String param) {
365                    return GetterUtil.getDouble(request.getParameter(param));
366            }
367    
368            public static double getDouble(
369                    HttpServletRequest request, String param, double defaultValue) {
370    
371                    return get(request, param, defaultValue);
372            }
373    
374            public static double getDouble(
375                    PortletRequest portletRequest, String param) {
376    
377                    return GetterUtil.getDouble(portletRequest.getParameter(param));
378            }
379    
380            public static double getDouble(
381                    PortletRequest portletRequest, String param, double defaultValue) {
382    
383                    return get(portletRequest, param, defaultValue);
384            }
385    
386            public static double getDouble(
387                    ServiceContext serviceContext, String param) {
388    
389                    return GetterUtil.getDouble(serviceContext.getAttribute(param));
390            }
391    
392            public static double getDouble(
393                    ServiceContext serviceContext, String param, double defaultValue) {
394    
395                    return get(serviceContext, param, defaultValue);
396            }
397    
398            public static double[] getDoubleValues(
399                    HttpServletRequest request, String param) {
400    
401                    return getDoubleValues(request, param, new double[0]);
402            }
403    
404            public static double[] getDoubleValues(
405                    HttpServletRequest request, String param, double[] defaultValue) {
406    
407                    return GetterUtil.getDoubleValues(
408                            request.getParameterValues(param), defaultValue);
409            }
410    
411            public static double[] getDoubleValues(
412                    PortletRequest portletRequest, String param) {
413    
414                    return getDoubleValues(portletRequest, param, new double[0]);
415            }
416    
417            public static double[] getDoubleValues(
418                    PortletRequest portletRequest, String param, double[] defaultValue) {
419    
420                    return GetterUtil.getDoubleValues(
421                            portletRequest.getParameterValues(param), defaultValue);
422            }
423    
424            public static double[] getDoubleValues(
425                    ServiceContext serviceContext, String param) {
426    
427                    return getDoubleValues(serviceContext, param, new double[0]);
428            }
429    
430            public static double[] getDoubleValues(
431                    ServiceContext serviceContext, String param, double[] defaultValue) {
432    
433                    return GetterUtil.getDoubleValues(
434                            serviceContext.getAttribute(param), defaultValue);
435            }
436    
437            public static float getFloat(HttpServletRequest request, String param) {
438                    return GetterUtil.getFloat(request.getParameter(param));
439            }
440    
441            public static float getFloat(
442                    HttpServletRequest request, String param, float defaultValue) {
443    
444                    return get(request, param, defaultValue);
445            }
446    
447            public static float getFloat(PortletRequest portletRequest, String param) {
448                    return GetterUtil.getFloat(portletRequest.getParameter(param));
449            }
450    
451            public static float getFloat(
452                    PortletRequest portletRequest, String param, float defaultValue) {
453    
454                    return get(portletRequest, param, defaultValue);
455            }
456    
457            public static float getFloat(ServiceContext serviceContext, String param) {
458                    return GetterUtil.getFloat(serviceContext.getAttribute(param));
459            }
460    
461            public static float getFloat(
462                    ServiceContext serviceContext, String param, float defaultValue) {
463    
464                    return get(serviceContext, param, defaultValue);
465            }
466    
467            public static float[] getFloatValues(
468                    HttpServletRequest request, String param) {
469    
470                    return getFloatValues(request, param, new float[0]);
471            }
472    
473            public static float[] getFloatValues(
474                    HttpServletRequest request, String param, float[] defaultValue) {
475    
476                    return GetterUtil.getFloatValues(
477                            request.getParameterValues(param), defaultValue);
478            }
479    
480            public static float[] getFloatValues(
481                    PortletRequest portletRequest, String param) {
482    
483                    return getFloatValues(portletRequest, param, new float[0]);
484            }
485    
486            public static float[] getFloatValues(
487                    PortletRequest portletRequest, String param, float[] defaultValue) {
488    
489                    return GetterUtil.getFloatValues(
490                            portletRequest.getParameterValues(param), defaultValue);
491            }
492    
493            public static float[] getFloatValues(
494                    ServiceContext serviceContext, String param) {
495    
496                    return getFloatValues(serviceContext, param, new float[0]);
497            }
498    
499            public static float[] getFloatValues(
500                    ServiceContext serviceContext, String param, float[] defaultValue) {
501    
502                    return GetterUtil.getFloatValues(
503                            serviceContext.getAttribute(param), defaultValue);
504            }
505    
506            public static int getInteger(HttpServletRequest request, String param) {
507                    return GetterUtil.getInteger(request.getParameter(param));
508            }
509    
510            public static int getInteger(
511                    HttpServletRequest request, String param, int defaultValue) {
512    
513                    return get(request, param, defaultValue);
514            }
515    
516            public static int getInteger(PortletRequest portletRequest, String param) {
517                    return GetterUtil.getInteger(portletRequest.getParameter(param));
518            }
519    
520            public static int getInteger(
521                    PortletRequest portletRequest, String param, int defaultValue) {
522    
523                    return get(portletRequest, param, defaultValue);
524            }
525    
526            public static int getInteger(ServiceContext serviceContext, String param) {
527                    return GetterUtil.getInteger(serviceContext.getAttribute(param));
528            }
529    
530            public static int getInteger(
531                    ServiceContext serviceContext, String param, int defaultValue) {
532    
533                    return get(serviceContext, param, defaultValue);
534            }
535    
536            public static int[] getIntegerValues(
537                    HttpServletRequest request, String param) {
538    
539                    return getIntegerValues(request, param, new int[0]);
540            }
541    
542            public static int[] getIntegerValues(
543                    HttpServletRequest request, String param, int[] defaultValue) {
544    
545                    return GetterUtil.getIntegerValues(
546                            request.getParameterValues(param), defaultValue);
547            }
548    
549            public static int[] getIntegerValues(
550                    PortletRequest portletRequest, String param) {
551    
552                    return getIntegerValues(portletRequest, param, new int[0]);
553            }
554    
555            public static int[] getIntegerValues(
556                    PortletRequest portletRequest, String param, int[] defaultValue) {
557    
558                    return GetterUtil.getIntegerValues(
559                            portletRequest.getParameterValues(param), defaultValue);
560            }
561    
562            public static int[] getIntegerValues(
563                    ServiceContext serviceContext, String param) {
564    
565                    return getIntegerValues(serviceContext, param, new int[0]);
566            }
567    
568            public static int[] getIntegerValues(
569                    ServiceContext serviceContext, String param, int[] defaultValue) {
570    
571                    return GetterUtil.getIntegerValues(
572                            serviceContext.getAttribute(param), defaultValue);
573            }
574    
575            public static long getLong(HttpServletRequest request, String param) {
576                    return GetterUtil.getLong(request.getParameter(param));
577            }
578    
579            public static long getLong(
580                    HttpServletRequest request, String param, long defaultValue) {
581    
582                    return get(request, param, defaultValue);
583            }
584    
585            public static long getLong(PortletRequest portletRequest, String param) {
586                    return GetterUtil.getLong(portletRequest.getParameter(param));
587            }
588    
589            public static long getLong(
590                    PortletRequest portletRequest, String param, long defaultValue) {
591    
592                    return get(portletRequest, param, defaultValue);
593            }
594    
595            public static long getLong(ServiceContext serviceContext, String param) {
596                    return GetterUtil.getLong(serviceContext.getAttribute(param));
597            }
598    
599            public static long getLong(
600                    ServiceContext serviceContext, String param, long defaultValue) {
601    
602                    return get(serviceContext, param, defaultValue);
603            }
604    
605            public static long[] getLongValues(
606                    HttpServletRequest request, String param) {
607    
608                    return getLongValues(request, param, new long[0]);
609            }
610    
611            public static long[] getLongValues(
612                    HttpServletRequest request, String param, long[] defaultValue) {
613    
614                    return GetterUtil.getLongValues(
615                            request.getParameterValues(param), defaultValue);
616            }
617    
618            public static long[] getLongValues(
619                    PortletRequest portletRequest, String param) {
620    
621                    return getLongValues(portletRequest, param, new long[0]);
622            }
623    
624            public static long[] getLongValues(
625                    PortletRequest portletRequest, String param, long[] defaultValue) {
626    
627                    return GetterUtil.getLongValues(
628                            portletRequest.getParameterValues(param), defaultValue);
629            }
630    
631            public static long[] getLongValues(
632                    ServiceContext serviceContext, String param) {
633    
634                    return getLongValues(serviceContext, param, new long[0]);
635            }
636    
637            public static long[] getLongValues(
638                    ServiceContext serviceContext, String param, long[] defaultValue) {
639    
640                    return GetterUtil.getLongValues(
641                            serviceContext.getAttribute(param), defaultValue);
642            }
643    
644            public static short getShort(HttpServletRequest request, String param) {
645                    return GetterUtil.getShort(request.getParameter(param));
646            }
647    
648            public static short getShort(
649                    HttpServletRequest request, String param, short defaultValue) {
650    
651                    return get(request, param, defaultValue);
652            }
653    
654            public static short getShort(PortletRequest portletRequest, String param) {
655                    return GetterUtil.getShort(portletRequest.getParameter(param));
656            }
657    
658            public static short getShort(
659                    PortletRequest portletRequest, String param, short defaultValue) {
660    
661                    return get(portletRequest, param, defaultValue);
662            }
663    
664            public static short getShort(ServiceContext serviceContext, String param) {
665                    return GetterUtil.getShort(serviceContext.getAttribute(param));
666            }
667    
668            public static short getShort(
669                    ServiceContext serviceContext, String param, short defaultValue) {
670    
671                    return get(serviceContext, param, defaultValue);
672            }
673    
674            public static short[] getShortValues(
675                    HttpServletRequest request, String param) {
676    
677                    return getShortValues(request, param, new short[0]);
678            }
679    
680            public static short[] getShortValues(
681                    HttpServletRequest request, String param, short[] defaultValue) {
682    
683                    return GetterUtil.getShortValues(
684                            request.getParameterValues(param), defaultValue);
685            }
686    
687            public static short[] getShortValues(
688                    PortletRequest portletRequest, String param) {
689    
690                    return getShortValues(portletRequest, param, new short[0]);
691            }
692    
693            public static short[] getShortValues(
694                    PortletRequest portletRequest, String param, short[] defaultValue) {
695    
696                    return GetterUtil.getShortValues(
697                            portletRequest.getParameterValues(param), defaultValue);
698            }
699    
700            public static short[] getShortValues(
701                    ServiceContext serviceContext, String param) {
702    
703                    return getShortValues(serviceContext, param, new short[0]);
704            }
705    
706            public static short[] getShortValues(
707                    ServiceContext serviceContext, String param, short[] defaultValue) {
708    
709                    return GetterUtil.getShortValues(
710                            serviceContext.getAttribute(param), defaultValue);
711            }
712    
713            public static String getString(HttpServletRequest request, String param) {
714                    return GetterUtil.getString(request.getParameter(param));
715            }
716    
717            public static String getString(
718                    HttpServletRequest request, String param, String defaultValue) {
719    
720                    return get(request, param, defaultValue);
721            }
722    
723            public static String getString(
724                    PortletRequest portletRequest, String param) {
725    
726                    return GetterUtil.getString(portletRequest.getParameter(param));
727            }
728    
729            public static String getString(
730                    PortletRequest portletRequest, String param, String defaultValue) {
731    
732                    return get(portletRequest, param, defaultValue);
733            }
734    
735            public static String getString(
736                    ServiceContext serviceContext, String param) {
737    
738                    return GetterUtil.getString(serviceContext.getAttribute(param));
739            }
740    
741            public static String getString(
742                    ServiceContext serviceContext, String param, String defaultValue) {
743    
744                    return get(serviceContext, param, defaultValue);
745            }
746    
747            public static void print(HttpServletRequest request) {
748                    Enumeration<String> enu = request.getParameterNames();
749    
750                    while (enu.hasMoreElements()) {
751                            String param = enu.nextElement();
752    
753                            String[] values = request.getParameterValues(param);
754    
755                            for (int i = 0; i < values.length; i++) {
756                                    System.out.println(param + "[" + i + "] = " + values[i]);
757                            }
758                    }
759            }
760    
761            public static void print(PortletRequest portletRequest) {
762                    Enumeration<String> enu = portletRequest.getParameterNames();
763    
764                    while (enu.hasMoreElements()) {
765                            String param = enu.nextElement();
766    
767                            String[] values = portletRequest.getParameterValues(param);
768    
769                            for (int i = 0; i < values.length; i++) {
770                                    System.out.println(param + "[" + i + "] = " + values[i]);
771                            }
772                    }
773            }
774    
775            public static void print(ServiceContext serviceContext) {
776                    Map<String, Serializable> attributes = serviceContext.getAttributes();
777    
778                    for (Map.Entry<String, Serializable> entry : attributes.entrySet()) {
779                            System.out.println(
780                                    entry.getKey() + " = " + String.valueOf(entry.getValue()));
781                    }
782            }
783    
784    }

  在上述的源代码中ParamUtil这个类又调用了GetterUtil这个类中的方法,ParamUtil这个类是干什么用的啊,估计大家会有疑问,这个很类的作用就是获取我们从界面上输入的参数,传给后台用的,比如界面上有一个输入的用户名(“username”),你想获取的时候怎么办啊,在servlet中我们可以用request.getParamter("username");就可以得到用户名,但是在liferay中我们需要这样写,ParamUtil.getString(actionRequest,"username",StringPool.BLACK);就可以了,我首先说一下这里面的参数,第一个参数不用说大家也估计能猜出来,就是一个请求,类似于servlet中request,第二个参数就是你在界面上定义的name,第三个我特别想说一下,你说编写liferay的人是不是脑子有坑,为什么在StringPool中定义那么多的常量,明明一个 StringPool.BLANK = "",直接在上述的方法中写一个""就可以了,为什么这个复杂,真心不明白,下面献上StringPool中的源代码

  package com.liferay.portal.kernel.util;
016    
017    /**
018     * @author Brian Wing Shun Chan
019     */
020    public class StringPool {
021    
022            public static final String AMPERSAND = "&";
023    
024            public static final String AMPERSAND_ENCODED = "&";
025    
026            public static final String APOSTROPHE = "'";
027    
028            public static final String AT = "@";
029    
030            public static final String BACK_SLASH = "\";
031    
032            public static final String BETWEEN = "BETWEEN";
033    
034            public static final String BLANK = "";
035    
036            public static final String CARET = "^";
037    
038            public static final String CDATA_CLOSE = "]]>";
039    
040            public static final String CDATA_OPEN = "<![CDATA[";
041    
042            public static final String CLOSE_BRACKET = "]";
043    
044            public static final String CLOSE_CURLY_BRACE = "}";
045    
046            public static final String CLOSE_PARENTHESIS = ")";
047    
048            public static final String COLON = ":";
049    
050            public static final String COMMA = ",";
051    
052            public static final String COMMA_AND_SPACE = ", ";
053    
054            public static final String DASH = "-";
055    
056            public static final String DOLLAR = "$";
057    
058            public static final String DOLLAR_AND_OPEN_CURLY_BRACE = "${";
059    
060            public static final String DOUBLE_APOSTROPHE = "''";
061    
062            public static final String DOUBLE_CLOSE_BRACKET = "]]";
063    
064            public static final String DOUBLE_CLOSE_CURLY_BRACE = "}}";
065    
066            public static final String DOUBLE_OPEN_BRACKET = "[[";
067    
068            public static final String DOUBLE_OPEN_CURLY_BRACE = "{{";
069    
070            public static final String DOUBLE_PERIOD = "..";
071    
072            public static final String DOUBLE_QUOTE = """";
073    
074            public static final String DOUBLE_SLASH = "//";
075    
076            public static final String DOUBLE_SPACE = "  ";
077    
078            public static final String EXCLAMATION = "!";
079    
080            public static final String EQUAL = "=";
081    
082            public static final String FALSE = "false";
083    
084            public static final String FORWARD_SLASH = "/";
085    
086            public static final String FOUR_SPACES = "    ";
087    
088            public static final String GRAVE_ACCENT = "`";
089    
090            public static final String GREATER_THAN = ">";
091    
092            public static final String GREATER_THAN_OR_EQUAL = ">=";
093    
094            public static final String INVERTED_EXCLAMATION = "u00A1";
095    
096            public static final String INVERTED_QUESTION = "u00BF";
097    
098            public static final String IS_NOT_NULL = "IS NOT NULL";
099    
100            public static final String IS_NULL = "IS NULL";
101    
102            public static final String ISO_8859_1 = "ISO-8859-1";
103    
104            public static final String LESS_THAN = "<";
105    
106            public static final String LESS_THAN_OR_EQUAL = "<=";
107    
108            public static final String LIKE = "LIKE";
109    
110            public static final String MINUS = "-";
111    
112            public static final String NBSP = " ";
113    
114            public static final String NEW_LINE = "
";
115    
116            public static final String NOT_EQUAL = "!=";
117    
118            public static final String NOT_LIKE = "NOT LIKE";
119    
120            public static final String NULL = "null";
121    
122            public static final String OPEN_BRACKET = "[";
123    
124            public static final String OPEN_CURLY_BRACE = "{";
125    
126            public static final String OPEN_PARENTHESIS = "(";
127    
128            public static final String PERCENT = "%";
129    
130            public static final String PERIOD = ".";
131    
132            public static final String PIPE = "|";
133    
134            public static final String PLUS = "+";
135    
136            public static final String POUND = "#";
137    
138            public static final String QUESTION = "?";
139    
140            public static final String QUOTE = """;
141    
142            public static final String RETURN = "
";
143    
144            public static final String RETURN_NEW_LINE = "
";
145    
146            public static final String SEMICOLON = ";";
147    
148            public static final String SLASH = FORWARD_SLASH;
149    
150            public static final String SPACE = " ";
151    
152            public static final String STAR = "*";
153    
154            public static final String TAB = "	";
155    
156            public static final String TILDE = "~";
157    
158            public static final String TRUE = "true";
159    
160            public static final String UNDERLINE = "_";
161    
162            public static final String UTC = "UTC";
163    
164            public static final String UTF8 = "UTF-8";
165    
166    }

  上述就是获取参数的源代码,不管是什么样类型的数据,后台都可以通过这种方式获得。今天就到这,有兴趣的朋友大家可以写一个简单的页面和portlet来测试一下。

原文地址:https://www.cnblogs.com/airycode/p/4812396.html