Browse Source

支持 action 形参注入

James 8 years ago
parent
commit
3cd1163895
32 changed files with 1344 additions and 5 deletions
  1. 2 2
      src/main/java/com/jfinal/aop/Invocation.java
  2. 8 0
      src/main/java/com/jfinal/core/Action.java
  3. 2 3
      src/main/java/com/jfinal/core/ActionMapping.java
  4. 35 0
      src/main/java/com/jfinal/core/paragetter/BeanGetter.java
  5. 52 0
      src/main/java/com/jfinal/core/paragetter/BigDecimalGetter.java
  6. 52 0
      src/main/java/com/jfinal/core/paragetter/BigIntegerGetter.java
  7. 40 0
      src/main/java/com/jfinal/core/paragetter/BooleanGetter.java
  8. 47 0
      src/main/java/com/jfinal/core/paragetter/DateGetter.java
  9. 50 0
      src/main/java/com/jfinal/core/paragetter/DoubleGetter.java
  10. 49 0
      src/main/java/com/jfinal/core/paragetter/EnumGetter.java
  11. 49 0
      src/main/java/com/jfinal/core/paragetter/FileGetter.java
  12. 49 0
      src/main/java/com/jfinal/core/paragetter/FloatGetter.java
  13. 22 0
      src/main/java/com/jfinal/core/paragetter/IParaGetter.java
  14. 53 0
      src/main/java/com/jfinal/core/paragetter/IntegerArrayGetter.java
  15. 39 0
      src/main/java/com/jfinal/core/paragetter/IntegerGetter.java
  16. 53 0
      src/main/java/com/jfinal/core/paragetter/LongArrayGetter.java
  17. 39 0
      src/main/java/com/jfinal/core/paragetter/LongGetter.java
  18. 35 0
      src/main/java/com/jfinal/core/paragetter/ModelGetter.java
  19. 35 0
      src/main/java/com/jfinal/core/paragetter/NullGetter.java
  20. 37 0
      src/main/java/com/jfinal/core/paragetter/Para.java
  21. 36 0
      src/main/java/com/jfinal/core/paragetter/ParaGetter.java
  22. 59 0
      src/main/java/com/jfinal/core/paragetter/ParaProcessor.java
  23. 147 0
      src/main/java/com/jfinal/core/paragetter/ParaProcessorBuilder.java
  24. 13 0
      src/main/java/com/jfinal/core/paragetter/RawPostData.java
  25. 21 0
      src/main/java/com/jfinal/core/paragetter/RawPostDataGetter.java
  26. 50 0
      src/main/java/com/jfinal/core/paragetter/ShortGetter.java
  27. 51 0
      src/main/java/com/jfinal/core/paragetter/SqlDateGetter.java
  28. 41 0
      src/main/java/com/jfinal/core/paragetter/StringArrayGetter.java
  29. 35 0
      src/main/java/com/jfinal/core/paragetter/StringGetter.java
  30. 51 0
      src/main/java/com/jfinal/core/paragetter/TimeGetter.java
  31. 51 0
      src/main/java/com/jfinal/core/paragetter/TimestampGetter.java
  32. 41 0
      src/main/java/com/jfinal/core/paragetter/UploadFileGetter.java

+ 2 - 2
src/main/java/com/jfinal/aop/Invocation.java

@@ -29,7 +29,7 @@ import net.sf.cglib.proxy.MethodProxy;
 public class Invocation {
 	
 	private Action action;
-	private static final Object[] NULL_ARGS = new Object[0];	// Prevent new Object[0] by jvm for paras of action invocation.
+
 	
 	boolean useInjectTarget;
 	private Object target;
@@ -50,7 +50,7 @@ public class Invocation {
 		this.action = action;
 		this.inters = action.getInterceptors();
 		this.target = controller;
-		this.args = NULL_ARGS;
+		this.args = action.getParameterGetter().get(controller);
 	}
 	
 	public Invocation(Object target, Method method, Object[] args, MethodProxy methodProxy, Interceptor[] inters) {

+ 8 - 0
src/main/java/com/jfinal/core/Action.java

@@ -18,6 +18,8 @@ package com.jfinal.core;
 
 import java.lang.reflect.Method;
 import com.jfinal.aop.Interceptor;
+import com.jfinal.core.paragetter.ParaProcessorBuilder;
+import com.jfinal.core.paragetter.ParaProcessor;
 
 /**
  * Action
@@ -31,6 +33,7 @@ public class Action {
 	private final String methodName;
 	private final Interceptor[] interceptors;
 	private final String viewPath;
+	private final ParaProcessor parameterGetter;
 	
 	public Action(String controllerKey, String actionKey, Class<? extends Controller> controllerClass, Method method, String methodName, Interceptor[] interceptors, String viewPath) {
 		this.controllerKey = controllerKey;
@@ -40,6 +43,7 @@ public class Action {
 		this.methodName = methodName;
 		this.interceptors = interceptors;
 		this.viewPath = viewPath;
+		this.parameterGetter = ParaProcessorBuilder.me().build(controllerClass, method);
 	}
 	
 	public Class<? extends Controller> getControllerClass() {
@@ -69,6 +73,10 @@ public class Action {
 	public String getMethodName() {
 		return methodName;
 	}
+	
+	public ParaProcessor getParameterGetter() {
+		return parameterGetter;
+	}
 }
 
 

+ 2 - 3
src/main/java/com/jfinal/core/ActionMapping.java

@@ -51,8 +51,7 @@ final class ActionMapping {
 		Set<String> excludedMethodName = new HashSet<String>();
 		Method[] methods = Controller.class.getMethods();
 		for (Method m : methods) {
-			if (m.getParameterTypes().length == 0)
-				excludedMethodName.add(m.getName());
+			excludedMethodName.add(m.getName());
 		}
 		return excludedMethodName;
 	}
@@ -78,7 +77,7 @@ final class ActionMapping {
 			Method[] methods = (sonOfController ? controllerClass.getDeclaredMethods() : controllerClass.getMethods());
 			for (Method method : methods) {
 				String methodName = method.getName();
-				if (excludedMethodName.contains(methodName) || method.getParameterTypes().length != 0)
+				if (excludedMethodName.contains(methodName))
 					continue ;
 				if (sonOfController && !Modifier.isPublic(method.getModifiers()))
 					continue ;

+ 35 - 0
src/main/java/com/jfinal/core/paragetter/BeanGetter.java

@@ -0,0 +1,35 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import com.jfinal.core.Controller;
+
+public class BeanGetter<T> extends ParaGetter<T> {
+	private final Class<T> modelClass;
+	public BeanGetter(Class<T> modelClass, String parameterName) {
+		super(parameterName, null);
+		this.modelClass = modelClass;
+	}
+	@Override
+	public T get(Controller c) {
+		return c.getBean(modelClass, this.getParameterName(),true);
+	}
+	
+	@Override
+	protected T to(String v) {
+		return null;
+	}
+}

+ 52 - 0
src/main/java/com/jfinal/core/paragetter/BigDecimalGetter.java

@@ -0,0 +1,52 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import java.math.BigDecimal;
+
+import com.jfinal.core.ActionException;
+import com.jfinal.core.Controller;
+import com.jfinal.kit.StrKit;
+import com.jfinal.render.RenderManager;
+
+public class BigDecimalGetter extends ParaGetter<BigDecimal> {
+
+	public BigDecimalGetter(String parameterName, String defaultValue) {
+		super(parameterName, defaultValue);
+	}
+
+	@Override
+	public BigDecimal get(Controller c) {
+		String value = c.getPara(this.getParameterName());
+		try {
+			if (StrKit.isBlank(value))
+				return this.getDefaultValue();
+			return to(value.trim());
+		} catch (Exception e) {
+			throw new ActionException(404, RenderManager.me().getRenderFactory().getErrorRender(404),
+					"Can not parse the parameter \"" + value + "\" to BigDecimal value.");
+		}
+	}
+
+	@Override
+	protected BigDecimal to(String v) {
+		if(StrKit.notBlank(v)){
+			return new BigDecimal(v);
+		}
+		return null;
+	}
+
+}

+ 52 - 0
src/main/java/com/jfinal/core/paragetter/BigIntegerGetter.java

@@ -0,0 +1,52 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import java.math.BigInteger;
+
+import com.jfinal.core.ActionException;
+import com.jfinal.core.Controller;
+import com.jfinal.kit.StrKit;
+import com.jfinal.render.RenderManager;
+
+public class BigIntegerGetter extends ParaGetter<BigInteger> {
+
+	public BigIntegerGetter(String parameterName, String defaultValue) {
+		super(parameterName, defaultValue);
+	}
+
+	@Override
+	public BigInteger get(Controller c) {
+		String value = c.getPara(this.getParameterName());
+		try {
+			if (StrKit.isBlank(value))
+				return this.getDefaultValue();
+			return to(value.trim());
+		} catch (Exception e) {
+			throw new ActionException(404, RenderManager.me().getRenderFactory().getErrorRender(404),
+					"Can not parse the parameter \"" + value + "\" to BigInteger value.");
+		}
+	}
+
+	@Override
+	protected BigInteger to(String v) {
+		if(StrKit.notBlank(v)){
+			return new BigInteger(v);
+		}
+		return null;
+	}
+
+}

+ 40 - 0
src/main/java/com/jfinal/core/paragetter/BooleanGetter.java

@@ -0,0 +1,40 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import com.jfinal.core.Controller;
+import com.jfinal.kit.StrKit;
+
+public class BooleanGetter extends ParaGetter<Boolean> {
+	
+	public BooleanGetter(String parameterName, String defaultValue) {
+		super(parameterName,defaultValue);
+	}
+
+	@Override
+	public Boolean get(Controller c) {
+		return c.getParaToBoolean(getParameterName(),getDefaultValue());
+	}
+
+	@Override
+	protected Boolean to(String v) {
+		if(StrKit.notBlank(v)){
+			return Boolean.parseBoolean(v);
+		}
+		return null;
+	}
+
+}

+ 47 - 0
src/main/java/com/jfinal/core/paragetter/DateGetter.java

@@ -0,0 +1,47 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import java.text.ParseException;
+
+import com.jfinal.core.Controller;
+import com.jfinal.core.converter.Converters.DateConverter;
+import com.jfinal.kit.StrKit;
+
+public class DateGetter extends ParaGetter<java.util.Date> {
+	private static DateConverter converter = new DateConverter();
+	public DateGetter(String parameterName, String defaultValue) {
+		super(parameterName, defaultValue);
+	}
+
+	@Override
+	public java.util.Date get(Controller c) {
+		return c.getParaToDate(getParameterName(), getDefaultValue());
+	}
+
+	@Override
+	protected java.util.Date to(String v) {
+		if(StrKit.isBlank(v)){
+			return null;
+		}
+		try {
+			return converter.convert(v);
+		} catch (ParseException e) {
+			return null;
+		}
+	}
+
+}

+ 50 - 0
src/main/java/com/jfinal/core/paragetter/DoubleGetter.java

@@ -0,0 +1,50 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import com.jfinal.core.ActionException;
+import com.jfinal.core.Controller;
+import com.jfinal.kit.StrKit;
+import com.jfinal.render.RenderManager;
+
+public class DoubleGetter extends ParaGetter<Double> {
+	
+	public DoubleGetter(String parameterName, String defaultValue) {
+		super(parameterName,defaultValue);
+	}
+
+	@Override
+	public Double get(Controller c) {
+		String value = c.getPara(this.getParameterName());
+		try {
+			if (StrKit.isBlank(value))
+				return this.getDefaultValue();
+			value = value.trim();
+			return to(value);
+		} catch (Exception e) {
+			throw new ActionException(404, RenderManager.me().getRenderFactory().getErrorRender(404),
+					"Can not parse the parameter \"" + value + "\" to Double value.");
+		}
+	}
+
+	@Override
+	protected Double to(String v) {
+		if(StrKit.notBlank(v)){
+			return Double.parseDouble(v);
+		}
+		return null;
+	}
+}

+ 49 - 0
src/main/java/com/jfinal/core/paragetter/EnumGetter.java

@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import com.jfinal.core.Controller;
+import com.jfinal.kit.StrKit;
+
+@SuppressWarnings({"unchecked", "rawtypes"})
+public class EnumGetter<T extends Enum> extends ParaGetter<T> {
+	private final Class<T> enumType;
+	public EnumGetter(Class<T> enumType, String parameterName, String defaultValue) {
+		super(parameterName, defaultValue);
+		this.enumType = enumType;
+	}
+
+	@Override
+	public T get(Controller c) {
+		String value = c.getPara(this.getParameterName());
+		if(StrKit.notBlank(value)){
+			return to(value);
+		}
+		return this.getDefaultValue();
+	}
+
+	@Override
+	protected T to(String v) {
+		if(StrKit.notBlank(v)){
+			try{
+				return (T) Enum.valueOf(this.enumType, v.trim());
+			}catch(Exception e){
+				return null;
+			}
+		}
+		return null;
+	}
+}

+ 49 - 0
src/main/java/com/jfinal/core/paragetter/FileGetter.java

@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import java.io.File;
+
+import com.jfinal.core.Controller;
+import com.jfinal.upload.UploadFile;
+
+public class FileGetter extends ParaGetter<File> {
+
+	public FileGetter(String parameterName,String defaultValue) {
+		super(parameterName,null);
+	}
+
+	@Override
+	public File get(Controller c) {
+		String parameterName = this.getParameterName();
+		UploadFile uf = null;
+		if(parameterName.isEmpty()){
+			uf = c.getFile();
+		}else{
+			uf = c.getFile(parameterName);
+		}
+		if(uf != null){
+			return uf.getFile();
+		}
+		return null;
+	}
+
+	@Override
+	protected File to(String v) {
+		return null;
+	}
+
+}

+ 49 - 0
src/main/java/com/jfinal/core/paragetter/FloatGetter.java

@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import com.jfinal.core.ActionException;
+import com.jfinal.core.Controller;
+import com.jfinal.kit.StrKit;
+import com.jfinal.render.RenderManager;
+
+public class FloatGetter extends ParaGetter<Float> {
+
+	public FloatGetter(String parameterName, String defaultValue) {
+		super(parameterName, defaultValue);
+	}
+
+	@Override
+	public Float get(Controller c) {
+		String value = c.getPara(this.getParameterName());
+		try {
+			if (StrKit.isBlank(value))
+				return this.getDefaultValue();
+			return to(value.trim());
+		} catch (Exception e) {
+			throw new ActionException(404, RenderManager.me().getRenderFactory().getErrorRender(404),
+					"Can not parse the parameter \"" + value + "\" to Float value.");
+		}
+	}
+
+	@Override
+	protected Float to(String v) {
+		if(StrKit.notBlank(v)){
+			return Float.parseFloat(v);
+		}
+		return null;
+	}
+}

+ 22 - 0
src/main/java/com/jfinal/core/paragetter/IParaGetter.java

@@ -0,0 +1,22 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import com.jfinal.core.Controller;
+
+public interface IParaGetter<T> {
+	public T get(Controller c);
+}

+ 53 - 0
src/main/java/com/jfinal/core/paragetter/IntegerArrayGetter.java

@@ -0,0 +1,53 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.jfinal.core.Controller;
+import com.jfinal.kit.StrKit;
+
+public class IntegerArrayGetter extends ParaGetter<Integer[]> {
+	
+	public IntegerArrayGetter(String parameterName, String defaultValue) {
+		super(parameterName,defaultValue);
+	}
+
+	@Override
+	public Integer[] get(Controller c) {
+		Integer[] ret = c.getParaValuesToInt(getParameterName());
+		if( null == ret) {
+			ret =  this.getDefaultValue();
+		}
+		return ret;
+	}
+
+	@Override
+	protected Integer[] to(String v) {
+		if(StrKit.notBlank(v)){
+			String[] ss = v.split(",");
+			List<Integer> ls = new ArrayList<Integer>(ss.length);
+			for(String s : ss){
+				if(StrKit.notBlank(s)){
+					ls.add(Integer.parseInt(s.trim()));
+				}
+			}
+			return ls.toArray(new Integer[0]);
+		}
+		return null;
+	}
+}

+ 39 - 0
src/main/java/com/jfinal/core/paragetter/IntegerGetter.java

@@ -0,0 +1,39 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import com.jfinal.core.Controller;
+import com.jfinal.kit.StrKit;
+
+public class IntegerGetter extends ParaGetter<Integer> {
+
+	public IntegerGetter(String parameterName, String defaultValue) {
+		super(parameterName, defaultValue);
+	}
+
+	@Override
+	public Integer get(Controller c) {
+		return c.getParaToInt(getParameterName(),getDefaultValue());
+	}
+
+	@Override
+	protected Integer to(String v) {
+		if(StrKit.notBlank(v)){
+			return Integer.parseInt(v);
+		}
+		return null;
+	}
+}

+ 53 - 0
src/main/java/com/jfinal/core/paragetter/LongArrayGetter.java

@@ -0,0 +1,53 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.jfinal.core.Controller;
+import com.jfinal.kit.StrKit;
+
+public class LongArrayGetter extends ParaGetter<Long[]> {
+
+	public LongArrayGetter(String parameterName, String defaultValue) {
+		super(parameterName,defaultValue);
+	}
+
+	@Override
+	public Long[] get(Controller c) {
+		Long[] ret =  c.getParaValuesToLong(getParameterName());
+		if( null == ret) {
+			ret =  this.getDefaultValue();
+		}
+		return ret;
+	}
+
+	@Override
+	protected Long[] to(String v) {
+		if(StrKit.notBlank(v)){
+			String[] ss = v.split(",");
+			List<Long> ls = new ArrayList<Long>(ss.length);
+			for(String s : ss){
+				if(StrKit.notBlank(s)){
+					ls.add(Long.parseLong(s.trim()));
+				}
+			}
+			return ls.toArray(new Long[0]);
+		}
+		return null;
+	}
+}

+ 39 - 0
src/main/java/com/jfinal/core/paragetter/LongGetter.java

@@ -0,0 +1,39 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import com.jfinal.core.Controller;
+import com.jfinal.kit.StrKit;
+
+public class LongGetter extends ParaGetter<Long> {
+	
+	public LongGetter(String parameterName, String defaultValue) {
+		super(parameterName,defaultValue);
+	}
+
+	@Override
+	public Long get(Controller c) {
+		return c.getParaToLong(getParameterName(),getDefaultValue());
+	}
+
+	@Override
+	protected Long to(String v) {
+		if(StrKit.notBlank(v)){
+			return Long.parseLong(v);
+		}
+		return null;
+	}
+}

+ 35 - 0
src/main/java/com/jfinal/core/paragetter/ModelGetter.java

@@ -0,0 +1,35 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import com.jfinal.core.Controller;
+
+public class ModelGetter<T> extends ParaGetter<T> {
+
+	private final Class<T> modelClass;
+	public ModelGetter(Class<T> modelClass, String parameterName) {
+		super(parameterName,null);
+		this.modelClass = modelClass;
+	}
+	@Override
+	public T get(Controller c) {
+		return c.getModel(modelClass, this.getParameterName(),true);
+	}
+	@Override
+	protected T to(String v) {
+		return null;
+	}
+}

+ 35 - 0
src/main/java/com/jfinal/core/paragetter/NullGetter.java

@@ -0,0 +1,35 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import com.jfinal.core.Controller;
+
+public class NullGetter extends ParaGetter<Object> {
+
+	public NullGetter(String parameterName, String defaultValue) {
+		super(null,null);
+	}
+
+	@Override
+	public Object get(Controller c) {
+		return null;
+	}
+
+	@Override
+	protected Object to(String v) {
+		return null;
+	}
+}

+ 37 - 0
src/main/java/com/jfinal/core/paragetter/Para.java

@@ -0,0 +1,37 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.PARAMETER})
+@Documented
+public @interface Para {
+    /**
+     * 对应到 HTTP 参数里的参数名称
+     */
+    String value();
+    
+    /**
+     * 默认值
+     */
+    String defaultValue() default "";
+}

+ 36 - 0
src/main/java/com/jfinal/core/paragetter/ParaGetter.java

@@ -0,0 +1,36 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+public abstract class ParaGetter<T> implements IParaGetter<T> {
+	private final String parameterName;
+	private final T defaultValue;
+	
+	protected final String getParameterName() {
+		return parameterName;
+	}
+	
+	protected final T getDefaultValue() {
+		return defaultValue;
+	}
+	
+	public ParaGetter(String parameterName, String defaultValue){
+		this.parameterName = parameterName;
+		this.defaultValue = to(defaultValue);
+	}
+	
+	protected abstract T to(String v);
+}

+ 59 - 0
src/main/java/com/jfinal/core/paragetter/ParaProcessor.java

@@ -0,0 +1,59 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.jfinal.core.Controller;
+
+public class ParaProcessor implements IParaGetter<Object[]>{
+	
+	private final List<IParaGetter<?>> paraGetters;
+	
+	private static final Object[] NULL_ARGS = new Object[0];
+	
+	public ParaProcessor(int paramCount){
+		if( paramCount > 0){
+			this.paraGetters = new ArrayList<IParaGetter<?>>(paramCount);
+		}else{
+			this.paraGetters = null;
+		}
+	}
+	public void addParaGetterToHeader(IParaGetter<?> paraGetter){
+		if(this.paraGetters != null){
+			this.paraGetters.add(0, paraGetter);
+		}
+	}
+	
+	public void addParaGetter(IParaGetter<?> paraGetter){
+		if(this.paraGetters != null){
+			this.paraGetters.add(paraGetter);
+		}
+	}
+	@Override
+	public Object[] get(Controller c) {
+		if(this.paraGetters != null){
+			List<Object> parameters = new ArrayList<Object>(this.paraGetters.size());
+			for(IParaGetter<?> paraGetter : this.paraGetters ){
+				parameters.add(paraGetter.get(c));
+			}
+			return parameters.toArray();
+		}else{
+			return NULL_ARGS;
+		}
+	}
+}

+ 147 - 0
src/main/java/com/jfinal/core/paragetter/ParaProcessorBuilder.java

@@ -0,0 +1,147 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.lang.reflect.Parameter;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.jfinal.core.Controller;
+
+public class ParaProcessorBuilder {
+
+	private final static ParaProcessorBuilder me = new ParaProcessorBuilder();
+	private Map<Class<?>, Holder> typeMap = new HashMap<Class<?>, Holder>();
+
+	private ParaProcessorBuilder() {
+		regist(short.class, ShortGetter.class, "0");
+		regist(int.class, IntegerGetter.class, "0");
+		regist(long.class, LongGetter.class, "0");
+		regist(float.class, FloatGetter.class, "0");
+		regist(double.class, DoubleGetter.class, "0");
+		regist(boolean.class, BooleanGetter.class, "false");
+		regist(java.lang.Short.class, ShortGetter.class, null);
+		regist(java.lang.Integer.class, IntegerGetter.class, null);
+		regist(java.lang.Long.class, LongGetter.class, null);
+		regist(java.lang.Float.class, FloatGetter.class, null);
+		regist(java.lang.Double.class, DoubleGetter.class, null);
+		regist(java.lang.Boolean.class, BooleanGetter.class, null);
+		regist(java.lang.String.class, StringGetter.class, null);
+		regist(java.util.Date.class, DateGetter.class, null);
+		regist(java.sql.Date.class, SqlDateGetter.class, null);
+		regist(java.sql.Time.class, TimeGetter.class, null);
+		regist(java.sql.Timestamp.class, TimestampGetter.class, null);
+		regist(java.math.BigDecimal.class, BigDecimalGetter.class, null);
+		regist(java.math.BigInteger.class, BigIntegerGetter.class, null);
+		regist(java.io.File.class, FileGetter.class, null);
+		regist(com.jfinal.upload.UploadFile.class, UploadFileGetter.class, null);
+		regist(java.lang.String[].class, StringArrayGetter.class, null);
+		regist(java.lang.Integer[].class, IntegerArrayGetter.class, null);
+		regist(java.lang.Long[].class, LongArrayGetter.class, null);
+		regist(com.jfinal.core.paragetter.RawPostData.class, RawPostDataGetter.class, null);
+		
+	}
+
+	public static ParaProcessorBuilder me() {
+		return me;
+	}
+	
+	/**
+	 * 注册一个类型对应的参数获取器 
+	 * ParameterGetterBuilder.me().regist(java.lang.String.class, StringParaGetter.class, null);
+	 * @param typeClass 类型,例如 java.lang.Integer.class
+	 * @param pgClass 参数获取器实现类,必须继承ParaGetter
+	 * @param defaultValue,默认值,比如int的默认值为0, java.lang.Integer的默认值为null
+	 */
+	public <T> void regist(Class<T> typeClass, Class<? extends ParaGetter<T>> pgClass, String defaultValue){
+		this.typeMap.put(typeClass, new Holder(pgClass, defaultValue));
+	}
+
+	public ParaProcessor build(Class<? extends Controller> controllerClass, Method method) {
+		final int parameterCount = method.getParameterCount();
+		ParaProcessor opag = new ParaProcessor(parameterCount);
+		if (0 == parameterCount) {
+			return opag;
+		}
+		for (Parameter p : method.getParameters()) {
+			IParaGetter<?> pg = createParaGetter(controllerClass, method, p);
+			//存在文件的情况下,文件需要优先获取才行
+			if (pg instanceof FileGetter) {
+				opag.addParaGetterToHeader(pg);
+			} else {
+				opag.addParaGetter(pg);
+			}
+		}
+		return opag;
+	}
+
+	@SuppressWarnings({ "unchecked", "rawtypes" })
+	private IParaGetter<?> createParaGetter(Class<? extends Controller> controllerClass, Method method,
+			Parameter p) {
+		String parameterName = p.getName();
+		String defaultValue = null;
+		Class<?> typeClass = p.getType();
+		Para para = p.getAnnotation(Para.class);
+		if (para != null) {
+			parameterName = para.value().trim();
+			defaultValue = para.defaultValue().trim();
+			if (defaultValue.isEmpty()) {
+				defaultValue = null;
+			}
+		}
+		Holder holder = typeMap.get(typeClass);
+		if (holder != null) {
+			if (null == defaultValue) {
+				defaultValue = holder.getDefaultValue();
+			}
+			try {
+				return holder.born(parameterName, defaultValue);
+			} catch (Exception e) {
+				throw new RuntimeException(e.getMessage(), e);
+			}
+		}
+		//枚举
+		if(Enum.class.isAssignableFrom(typeClass)){
+			return new EnumGetter(typeClass,parameterName,defaultValue);
+		}else if (com.jfinal.plugin.activerecord.IBean.class.isAssignableFrom(typeClass)) {
+			//实现了IBean接口,优先按BeanGetter来处理。
+			return new BeanGetter(typeClass, parameterName);
+		}else if (com.jfinal.plugin.activerecord.Model.class.isAssignableFrom(typeClass)) {
+			return new ModelGetter(typeClass, parameterName);
+		} else {
+			return new BeanGetter(typeClass, parameterName);
+		}
+	}
+
+	private static class Holder {
+		private final String defaultValue;
+		private final Class<? extends ParaGetter<?>> clazz;
+
+		Holder(Class<? extends ParaGetter<?>> clazz, String defaultValue) {
+			this.clazz = clazz;
+			this.defaultValue = defaultValue;
+		}
+		final String getDefaultValue() {
+			return defaultValue;
+		}
+		ParaGetter<?> born(String parameterName, String defaultValue) throws Exception {
+			Constructor<? extends ParaGetter<?>> con = clazz.getConstructor(String.class, String.class);
+			return con.newInstance(parameterName, defaultValue);
+		}
+	}
+}

+ 13 - 0
src/main/java/com/jfinal/core/paragetter/RawPostData.java

@@ -0,0 +1,13 @@
+package com.jfinal.core.paragetter;
+
+public class RawPostData {
+	private final String data;
+
+	public RawPostData(String data) {
+		this.data = data;
+	}
+
+	public final String getData() {
+		return data;
+	}
+}

+ 21 - 0
src/main/java/com/jfinal/core/paragetter/RawPostDataGetter.java

@@ -0,0 +1,21 @@
+package com.jfinal.core.paragetter;
+
+import com.jfinal.core.Controller;
+import com.jfinal.kit.HttpKit;
+
+public class RawPostDataGetter extends ParaGetter<RawPostData>{
+
+	public RawPostDataGetter(String parameterName, String defaultValue) {
+		super(parameterName, defaultValue);
+	}
+
+	@Override
+	public RawPostData get(Controller c) {
+		return new RawPostData(HttpKit.readData(c.getRequest()));
+	}
+
+	@Override
+	protected RawPostData to(String v) {
+		return new RawPostData(v);
+	}
+}

+ 50 - 0
src/main/java/com/jfinal/core/paragetter/ShortGetter.java

@@ -0,0 +1,50 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import com.jfinal.core.ActionException;
+import com.jfinal.core.Controller;
+import com.jfinal.kit.StrKit;
+import com.jfinal.render.RenderManager;
+
+public class ShortGetter extends ParaGetter<Short> {
+	
+	public ShortGetter(String parameterName, String defaultValue) {
+		super(parameterName,defaultValue);
+	}
+
+	@Override
+	public Short get(Controller c) {
+		String value = c.getPara(this.getParameterName());
+		try {
+			if (StrKit.isBlank(value))
+				return this.getDefaultValue();
+			return to(value.trim());
+		}
+		catch (Exception e) {
+			throw new ActionException(404, RenderManager.me().getRenderFactory().getErrorRender(404),  "Can not parse the parameter \"" + value + "\" to Short value.");
+		}
+	}
+
+	@Override
+	protected Short to(String v) {
+		if(StrKit.notBlank(v)){
+			return Short.parseShort(v);
+		}
+		return null;
+	}
+
+}

+ 51 - 0
src/main/java/com/jfinal/core/paragetter/SqlDateGetter.java

@@ -0,0 +1,51 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import java.text.ParseException;
+
+import com.jfinal.core.Controller;
+import com.jfinal.core.converter.Converters.SqlDateConverter;
+import com.jfinal.kit.StrKit;
+
+public class SqlDateGetter extends ParaGetter<java.sql.Date> {
+	private static SqlDateConverter converter = new SqlDateConverter();
+	public SqlDateGetter(String parameterName, String defaultValue) {
+		super(parameterName, defaultValue);
+	}
+
+	@Override
+	public java.sql.Date get(Controller c) {
+		String value = c.getPara(this.getParameterName());
+		if(StrKit.notBlank(value)){
+			return to(value);
+		}
+		return this.getDefaultValue();
+	}
+
+	@Override
+	protected java.sql.Date to(String v) {
+		if(StrKit.isBlank(v)){
+			return null;
+		}
+		try {
+			return converter.convert(v);
+		} catch (ParseException e) {
+			return null;
+		}
+	}
+
+}

+ 41 - 0
src/main/java/com/jfinal/core/paragetter/StringArrayGetter.java

@@ -0,0 +1,41 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import com.jfinal.core.Controller;
+import com.jfinal.kit.StrKit;
+
+public class StringArrayGetter extends ParaGetter<String[]> {
+	
+	public StringArrayGetter(String parameterName, String defaultValue) {
+		super(parameterName,defaultValue);
+	}
+	@Override
+	public String[] get(Controller c) {
+		String[] ret = c.getParaValues(getParameterName());
+		if( null == ret) {
+			ret =  this.getDefaultValue();
+		}
+		return ret;
+	}
+	@Override
+	protected String[] to(String v) {
+		if(StrKit.notBlank(v)){
+			return v.split(",");
+		}
+		return null;
+	}
+}

+ 35 - 0
src/main/java/com/jfinal/core/paragetter/StringGetter.java

@@ -0,0 +1,35 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import com.jfinal.core.Controller;
+
+public class StringGetter extends ParaGetter<String> {
+
+	public StringGetter(String parameterName, String defaultValue){
+		super(parameterName, defaultValue);
+	}
+
+	@Override
+	public String get(Controller c) {
+		return c.getPara(getParameterName(), getDefaultValue());
+	}
+
+	@Override
+	protected String to(String v) {
+		return v;
+	}
+}

+ 51 - 0
src/main/java/com/jfinal/core/paragetter/TimeGetter.java

@@ -0,0 +1,51 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import java.text.ParseException;
+
+import com.jfinal.core.Controller;
+import com.jfinal.core.converter.Converters.TimeConverter;
+import com.jfinal.kit.StrKit;
+
+public class TimeGetter extends ParaGetter<java.sql.Time> {
+	private static TimeConverter converter = new TimeConverter();
+	public TimeGetter(String parameterName, String defaultValue) {
+		super(parameterName, defaultValue);
+	}
+
+	@Override
+	public java.sql.Time get(Controller c) {
+		String value = c.getPara(this.getParameterName());
+		if(StrKit.notBlank(value)){
+			return to(value);
+		}
+		return this.getDefaultValue();
+	}
+
+	@Override
+	protected java.sql.Time to(String v) {
+		if(StrKit.isBlank(v)){
+			return null;
+		}
+		try {
+			return converter.convert(v);
+		} catch (ParseException e) {
+			return null;
+		}
+	}
+
+}

+ 51 - 0
src/main/java/com/jfinal/core/paragetter/TimestampGetter.java

@@ -0,0 +1,51 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import java.text.ParseException;
+
+import com.jfinal.core.Controller;
+import com.jfinal.core.converter.Converters.TimestampConverter;
+import com.jfinal.kit.StrKit;
+
+public class TimestampGetter extends ParaGetter<java.sql.Timestamp> {
+	private static TimestampConverter converter = new TimestampConverter();
+	public TimestampGetter(String parameterName, String defaultValue) {
+		super(parameterName, defaultValue);
+	}
+
+	@Override
+	public java.sql.Timestamp get(Controller c) {
+		String value = c.getPara(this.getParameterName());
+		if(StrKit.notBlank(value)){
+			return to(value);
+		}
+		return this.getDefaultValue();
+	}
+
+	@Override
+	protected java.sql.Timestamp to(String v) {
+		if(StrKit.isBlank(v)){
+			return null;
+		}
+		try {
+			return converter.convert(v);
+		} catch (ParseException e) {
+			return null;
+		}
+	}
+
+}

+ 41 - 0
src/main/java/com/jfinal/core/paragetter/UploadFileGetter.java

@@ -0,0 +1,41 @@
+/**
+ * Copyright (c) 2011-2017, 玛雅牛 (myaniu AT gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jfinal.core.paragetter;
+
+import com.jfinal.core.Controller;
+import com.jfinal.upload.UploadFile;
+
+public class UploadFileGetter extends ParaGetter<UploadFile> {
+
+	public UploadFileGetter(String parameterName,String defaultValue) {
+		super(parameterName,null);
+	}
+
+	@Override
+	public UploadFile get(Controller c) {
+		String parameterName = this.getParameterName();
+		if(parameterName.isEmpty()){
+			return c.getFile();
+		}
+		return c.getFile(parameterName);
+	}
+
+	@Override
+	protected UploadFile to(String v) {
+		return null;
+	}
+
+}