📄 commonaction.jsp
字号:
<%@ page contentType="text/html; charset=GBK"%>
<%@page errorPage="/common/errhand.jsp"%>
<%@ page
import="org.apache.commons.beanutils.MethodUtils,
java.lang.reflect.*,
cn.com.juneng.system.common.BaseForm" %>
<%@ page
import="org.apache.commons.lang.builder.ToStringBuilder,
org.apache.commons.lang.builder.ToStringStyle" %>
<%!
private static Class[][] REQUEST_METHOD_TYPES = {
{HttpServletRequest.class, HttpServletResponse.class},
{HttpServletRequest.class, HttpServletResponse.class, BaseForm.class}
};
private void pageForward(String url,HttpServletRequest request,HttpServletResponse response)
throws Exception{
if(url!=null){
request.setAttribute("Url",url);
}
}
private void pageRedirect(String url,HttpServletRequest request,HttpServletResponse response)
throws Exception{
response.sendRedirect(request.getContextPath()+url);
}
private boolean processRequest(HttpServletRequest request,
HttpServletResponse response,
BaseForm bForm)
throws Throwable{
request.removeAttribute("Message");
request.removeAttribute("Url");
request.removeAttribute("Script");
if(bForm.getActionType()==null){
bForm.setActionType("list");
}
try {
Method method = null;
for(int i=0; i< REQUEST_METHOD_TYPES.length; i++){
try{
method = this.getClass().getMethod(bForm.getActionType(), REQUEST_METHOD_TYPES[i]);
//debug(method);
break;
}catch(Exception e){
//ignore
//e.printStackTrace();
}
}
if(method==null){
throw new Exception("方法:"+bForm.getActionType()+" 未定义!");
}
if(method.getParameterTypes().length==2){
method.invoke(this,new Object[]{request,response});
}else if(method.getParameterTypes().length==3){
method.invoke(this,new Object[]{request,response,bForm});
}else{
throw new Exception("使用错误!");
}
} catch(Exception e){
if(e.getCause()!=null){
e.getCause().printStackTrace();
throw e.getCause();
}else{
e.printStackTrace();
throw e;
}
}
String url = (String)request.getAttribute("Url");
if(request.getAttribute("Message")==null&&url!=null){
request.getRequestDispatcher(url).forward(request,response);
}else{
request.getRequestDispatcher("/common/result.jsp").forward(request,response);
}
return true;
}
public void debug(Object o){
if(o == null) return;
String toString = o.toString();
if(o instanceof String){
toString = (String)o;
} else if(o instanceof Method){
toString = o.toString();
} else {
toString = ToStringBuilder.reflectionToString(o, ToStringStyle.MULTI_LINE_STYLE);
}
if(o instanceof Throwable){
((Throwable)o).printStackTrace();
} else {
System.out.println("-->>\tDebug#["+new java.sql.Timestamp(System.currentTimeMillis())+"] - \n\t"+toString);
}
}
public void error(Object o){
if(o == null) return;
if(o instanceof Throwable){
((Throwable)o).printStackTrace();
} else {
System.out.println("-->>\tDebug#["+new java.sql.Timestamp(System.currentTimeMillis())+"] - "+o);
}
}
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -