package com.hunantv.fw;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hunantv.fw.view.JsonView;
import com.hunantv.fw.view.RedirectView;
import com.hunantv.fw.view.StringView;
import com.hunantv.fw.view.View;

public class Controller {

	protected HttpServletRequest request;
	protected HttpServletResponse response;

	public HttpServletRequest getRequest() {
		return request;
	}

	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}

	public HttpServletResponse getResponse() {
		return response;
	}

	public void setResponse(HttpServletResponse response) {
		this.response = response;
	}

	public View renderString(String str) {
		return new StringView(str);
	}

	public View renderJson(Object object) {
		return new JsonView(object);
	}

	public View redirect(String str) {
		return new RedirectView(str);
	}
}

@@ -18,16 +18,65 @@
 tv.fw;%0A%0A
+import java.util.Arrays;%0Aimport java.util.List;%0A%0A
 import j
@@ -113,16 +113,16 @@
 equest;%0A
-
 import j
@@ -161,16 +161,56 @@
 ponse;%0A%0A
+import com.hunantv.fw.utils.StringUtil;%0A
 import c
@@ -942,32 +942,32 @@
 t(String str) %7B%0A
-
 %09%09return new Red
@@ -984,11 +984,1433 @@
 str);%0A%09%7D
+%0A%0A%09public Integer getIntegerParam(String name) %7B%0A%09%09return getIntegerParam(name, null);%0A%09%7D%0A%0A%09public Integer getIntegerParam(String name, Integer defaultValue) %7B%0A%09%09String value = this.request.getParameter(name);%0A%09%09if (value != null)%0A%09%09%09return Integer.valueOf(value);%0A%09%09return defaultValue;%0A%09%7D%0A%0A%09public Long getLongParam(String name) %7B%0A%09%09return getLongParam(name, null);%0A%09%7D%0A%0A%09public Long getLongParam(String name, Long defaultValue) %7B%0A%09%09String value = this.request.getParameter(name);%0A%09%09if (value != null)%0A%09%09%09return Long.valueOf(value);%0A%09%09return defaultValue;%0A%09%7D%0A%0A%09public Float getFloatParam(String name) %7B%0A%09%09return getFloatParam(name, null);%0A%09%7D%0A%0A%09public Float getFloatParam(String name, Float defaultValue) %7B%0A%09%09String value = this.request.getParameter(name);%0A%09%09if (value != null)%0A%09%09%09return Float.valueOf(value);%0A%09%09return defaultValue;%0A%09%7D%0A%0A%09public Double getDoubleParam(String name) %7B%0A%09%09return getDoubleParam(name, null);%0A%09%7D%0A%0A%09public Double getDoubleParam(String name, Double defaultValue) %7B%0A%09%09String value = this.request.getParameter(name);%0A%09%09if (value != null)%0A%09%09%09return Double.valueOf(value);%0A%09%09return defaultValue;%0A%09%7D%0A%0A%09public List getListParam(String name) %7B%0A%09%09return this.getListParam(name, null);%0A%09%7D%0A%0A%09public List getListParam(String name, List defaultValue) %7B%0A%09%09String value = this.request.getParameter(name);%0A%09%09if (value != null) %7B%0A%09%09%09return Arrays.asList(StringUtil.split(value, %22,%22));%0A%09%09%7D%0A%09%09return defaultValue;%0A%09%7D
 %0A%7D%0A

add get parameter with expected type