|
@@ -1,6 +1,7 @@
|
|
|
package com.yiidata.katta.ui.handle;
|
|
package com.yiidata.katta.ui.handle;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.yiidata.katta.ui.annaotion.Path;
|
|
|
import org.apache.commons.lang.exception.ExceptionUtils;
|
|
import org.apache.commons.lang.exception.ExceptionUtils;
|
|
|
|
|
|
|
|
import javax.servlet.ServletException;
|
|
import javax.servlet.ServletException;
|
|
@@ -46,15 +47,22 @@ public class DynamicRequestServlet extends HttpServlet {
|
|
|
private final Method method;
|
|
private final Method method;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 当前方法上 Path
|
|
|
|
|
+ */
|
|
|
|
|
+ protected final Path pathAnno;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 输出的字符编码
|
|
* 输出的字符编码
|
|
|
*/
|
|
*/
|
|
|
protected Charset utf8 = Charset.forName("utf-8");
|
|
protected Charset utf8 = Charset.forName("utf-8");
|
|
|
|
|
|
|
|
|
|
|
|
|
- public DynamicRequestServlet(Object instance, Method method) {
|
|
|
|
|
|
|
+ public DynamicRequestServlet(Object instance, Method method, Path pathAnno) {
|
|
|
this.instance = instance;
|
|
this.instance = instance;
|
|
|
this.method = method;
|
|
this.method = method;
|
|
|
|
|
+ this.pathAnno = pathAnno;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -75,8 +83,8 @@ public class DynamicRequestServlet extends HttpServlet {
|
|
|
if(r != null) {
|
|
if(r != null) {
|
|
|
if(r instanceof String) {
|
|
if(r instanceof String) {
|
|
|
resp.setCharacterEncoding(utf8.name());
|
|
resp.setCharacterEncoding(utf8.name());
|
|
|
- resp.setContentType("text/html; charset=" + utf8);
|
|
|
|
|
- resp.setHeader("Content-type", "text/html;charset=" + utf8);
|
|
|
|
|
|
|
+ resp.setContentType(pathAnno.contentType() + "; charset=" + utf8);
|
|
|
|
|
+ resp.setHeader("Content-type", pathAnno.contentType()+ ";charset=" + utf8);
|
|
|
new FreemarkerView((String)r).out(new OutputStreamWriter(out, utf8), params);
|
|
new FreemarkerView((String)r).out(new OutputStreamWriter(out, utf8), params);
|
|
|
} else if((r instanceof Map) || (r instanceof Collection)) {
|
|
} else if((r instanceof Map) || (r instanceof Collection)) {
|
|
|
resp.setCharacterEncoding("utf-8");
|
|
resp.setCharacterEncoding("utf-8");
|