Search in sources :

Example 1 with Request

use of org.axe.annotation.mvc.Request in project Axe by DongyuCai.

the class TestController method postPathParam2.

@Request(value = "/post100/4{id}_{name}", method = RequestMethod.POST)
public Data postPathParam2(@RequestParam("id") String id, Param param) {
    System.out.println("postPathParam2");
    Data data = analysisParam(param);
    return data;
}
Also used : Data(org.axe.bean.mvc.Data) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(org.axe.annotation.mvc.Request)

Example 2 with Request

use of org.axe.annotation.mvc.Request in project Axe by DongyuCai.

the class TestController method forward.

@Request(value = "/forward", method = RequestMethod.GET)
public View forward() {
    //浏览器端跳转
    View v = new View("someOneElse");
    v.addModel("arg1", "val1");
    return v;
}
Also used : View(org.axe.bean.mvc.View) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(org.axe.annotation.mvc.Request)

Example 3 with Request

use of org.axe.annotation.mvc.Request in project Axe by DongyuCai.

the class HomeController method tns.

@Request(value = "/tns", method = RequestMethod.GET)
public void tns(@RequestParam("token") String token, HttpServletRequest request, HttpServletResponse response) {
    String contextPath = request.getContextPath();
    StringBuilder html = new StringBuilder();
    html.append("<!DOCTYPE html>");
    html.append("<html>");
    html.append("<head>");
    html.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />");
    html.append("<title>axe tns</title>");
    html.append("</head>");
    html.append("<body>");
    html.append("<table width=\"100%\">");
    html.append("<tr><td align=\"right\">");
    if (ConfigHelper.getAxeSignIn()) {
        html.append("<a style=\"font-size: 15px;color: #AE0000\" href=\"" + contextPath + "/axe/sign-out?token=" + token + "\"><b>退出</b></a>");
    }
    html.append("&nbsp;<a style=\"font-size: 15px;color: #AE0000\" href=\"" + contextPath + "/axe?token=" + token + "\"><b>首页</b></a>");
    html.append("</td></tr>");
    Set<Class<?>> serviceClassSet = ClassHelper.getClassSetByAnnotation(Service.class);
    List<Method> tnsMethods = new ArrayList<>();
    for (Class<?> serviceClass : serviceClassSet) {
        List<Method> methods = ReflectionUtil.getMethodByAnnotation(serviceClass, Tns.class);
        if (CollectionUtil.isNotEmpty(methods)) {
            tnsMethods.addAll(methods);
        }
    }
    html.append("<tr><td align=\"center\"><font size=\"28\">Tns point x" + tnsMethods.size() + "</font></td></tr>");
    html.append("");
    html.append("<tr><td><table cellspacing=\"0px\"><tr><td style=\"background-color: #AE0000\">");
    html.append("&nbsp;<font color=\"white\"><b>Tns point</b></font>&nbsp;");
    html.append("</td></tr></table></td></tr>");
    html.append("");
    html.append("<tr><td height=\"2px\" style=\"background-color: #AE0000\"></td></tr>");
    html.append("<tr><td>");
    html.append("<table width=\"100%\">");
    html.append("<tr style=\"background-color: #F0F0F0;\">");
    html.append("<td align=\"left\">&nbsp;</td>");
    html.append("<td align=\"left\"><b>Method</b></td>");
    html.append("</tr>");
    for (Method method : tnsMethods) {
        html.append("<tr>");
        html.append("<td align=\"left\">&nbsp;</td>");
        html.append("<td align=\"left\">" + method.toString() + "</td>");
        html.append("</tr>");
    }
    html.append("</table>");
    html.append("</td></tr>");
    html.append("</table>");
    html.append("</body>");
    html.append("</html>");
    printHtml(response, html.toString());
}
Also used : ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) RequestMethod(org.axe.constant.RequestMethod) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(org.axe.annotation.mvc.Request)

Example 4 with Request

use of org.axe.annotation.mvc.Request in project Axe by DongyuCai.

the class HomeController method dataSource.

@Request(value = "/dataSource", method = RequestMethod.GET)
public void dataSource(@RequestParam("token") String token, HttpServletRequest request, HttpServletResponse response) {
    String contextPath = request.getContextPath();
    StringBuilder html = new StringBuilder();
    html.append("<!DOCTYPE html>");
    html.append("<html>");
    html.append("<head>");
    html.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />");
    html.append("<title>axe datasource</title>");
    html.append("</head>");
    html.append("<body>");
    html.append("<table width=\"100%\">");
    html.append("<tr><td align=\"right\">");
    if (ConfigHelper.getAxeSignIn()) {
        html.append("<a style=\"font-size: 15px;color: #AE0000\" href=\"" + contextPath + "/axe/sign-out?token=" + token + "\"><b>退出</b></a>");
    }
    html.append("&nbsp;<a style=\"font-size: 15px;color: #AE0000\" href=\"" + contextPath + "/axe?token=" + token + "\"><b>首页</b></a>");
    html.append("</td></tr>");
    Map<String, BaseDataSource> dataSourceMap = DataSourceHelper.getDataSourceAll();
    html.append("<tr><td align=\"center\"><font size=\"28\">DataSource x" + dataSourceMap.size() + "</font></td></tr>");
    html.append("");
    html.append("<tr><td><table cellspacing=\"0px\"><tr><td style=\"background-color: #AE0000\">");
    html.append("&nbsp;<font color=\"white\"><b>DataSource</b></font>&nbsp;");
    html.append("</td></tr></table></td></tr>");
    html.append("");
    html.append("<tr><td height=\"2px\" style=\"background-color: #AE0000\"></td></tr>");
    html.append("<tr><td>");
    html.append("<table width=\"100%\">");
    html.append("<tr style=\"background-color: #F0F0F0;\">");
    html.append("<td align=\"left\">&nbsp;</td>");
    html.append("<td align=\"left\"><b>Name</b></td>");
    html.append("<td align=\"left\"><b>Driver</b></td>");
    html.append("<td align=\"left\"><b>Url</b></td>");
    html.append("<td align=\"left\"><b>Username</b></td>");
    html.append("<td align=\"left\"><b>Password</b></td>");
    html.append("<td align=\"left\"><b>Class</b></td>");
    html.append("</tr>");
    for (Map.Entry<String, BaseDataSource> entry : dataSourceMap.entrySet()) {
        String dataSourceName = entry.getKey();
        BaseDataSource dataSource = entry.getValue();
        html.append("<tr>");
        html.append("<td align=\"left\">&nbsp;</td>");
        html.append("<td align=\"left\">" + dataSourceName + "</td>");
        html.append("<td align=\"left\">" + dataSource.setJdbcDriver() + "</td>");
        html.append("<td align=\"left\">" + dataSource.setJdbcUrl() + "</td>");
        html.append("<td align=\"left\">" + dataSource.setJdbcUserName() + "</td>");
        html.append("<td align=\"left\">" + dataSource.setJdbcPassword() + "</td>");
        html.append("<td align=\"left\">" + dataSource.getClass() + "</td>");
        html.append("</tr>");
    }
    html.append("</table>");
    html.append("</td></tr>");
    html.append("</table>");
    html.append("</body>");
    html.append("</html>");
    printHtml(response, html.toString());
}
Also used : BaseDataSource(org.axe.interface_.persistence.BaseDataSource) HashMap(java.util.HashMap) Map(java.util.Map) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(org.axe.annotation.mvc.Request)

Example 5 with Request

use of org.axe.annotation.mvc.Request in project Axe by DongyuCai.

the class HomeController method filter.

@Request(value = "/filter", method = RequestMethod.GET)
public void filter(@RequestParam("token") String token, HttpServletRequest request, HttpServletResponse response) {
    String contextPath = request.getContextPath();
    StringBuilder html = new StringBuilder();
    html.append("<!DOCTYPE html>");
    html.append("<html>");
    html.append("<head>");
    html.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />");
    html.append("<title>axe filter</title>");
    html.append("</head>");
    html.append("<body>");
    html.append("<table width=\"100%\">");
    html.append("<tr><td align=\"right\">");
    if (ConfigHelper.getAxeSignIn()) {
        html.append("<a style=\"font-size: 15px;color: #AE0000\" href=\"" + contextPath + "/axe/sign-out?token=" + token + "\"><b>退出</b></a>");
    }
    html.append("&nbsp;<a style=\"font-size: 15px;color: #AE0000\" href=\"" + contextPath + "/axe?token=" + token + "\"><b>首页</b></a>");
    html.append("</td></tr>");
    List<Filter> filterList = FilterHelper.getSortedFilterList();
    html.append("<tr><td align=\"center\"><font size=\"28\">Filter list x" + filterList.size() + "</font></td></tr>");
    html.append("");
    html.append("<tr><td><table cellspacing=\"0px\"><tr><td style=\"background-color: #AE0000\">");
    html.append("&nbsp;<font color=\"white\"><b>Filter</b></font>&nbsp;");
    html.append("</td></tr></table></td></tr>");
    html.append("");
    html.append("<tr><td height=\"2px\" style=\"background-color: #AE0000\"></td></tr>");
    html.append("<tr><td>");
    html.append("<table width=\"100%\">");
    html.append("<tr style=\"background-color: #F0F0F0;\">");
    html.append("<td align=\"left\">&nbsp;</td>");
    html.append("<td align=\"left\"><b>Level</b></td>");
    html.append("<td align=\"left\"><b>Class</b></td>");
    html.append("<td align=\"left\"><b>Mapping</b></td>");
    html.append("<td align=\"left\"><b>NotMapping</b></td>");
    html.append("</tr>");
    int id = 1;
    for (Filter filter : filterList) {
        html.append("<tr>");
        html.append("<td align=\"left\">" + (id++) + "</td>");
        html.append("<td align=\"left\">" + filter.setLevel() + "</td>");
        html.append("<td align=\"left\">" + filter.getClass() + "</td>");
        Pattern mappingPattern = filter.setMapping();
        String mappingRegex = mappingPattern == null ? "" : mappingPattern.toString();
        html.append("<td align=\"left\">" + mappingRegex + "</td>");
        Pattern notMappingPattern = filter.setNotMapping();
        String notMappingRegex = notMappingPattern == null ? "" : notMappingPattern.toString();
        html.append("<td align=\"left\">" + notMappingRegex + "</td>");
        html.append("</tr>");
    }
    html.append("</table>");
    html.append("</td></tr>");
    html.append("</table>");
    html.append("</body>");
    html.append("</html>");
    printHtml(response, html.toString());
}
Also used : Pattern(java.util.regex.Pattern) Filter(org.axe.interface_.mvc.Filter) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(org.axe.annotation.mvc.Request)

Aggregations

Request (org.axe.annotation.mvc.Request)15 HttpServletRequest (javax.servlet.http.HttpServletRequest)12 Method (java.lang.reflect.Method)4 Controller (org.axe.annotation.ioc.Controller)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Data (org.axe.bean.mvc.Data)3 RequestMethod (org.axe.constant.RequestMethod)3 List (java.util.List)2 Pattern (java.util.regex.Pattern)2 Handler (org.axe.bean.mvc.Handler)2 RestException (org.axe.exception.RestException)2 Filter (org.axe.interface_.mvc.Filter)2 PrintWriter (java.io.PrintWriter)1 Annotation (java.lang.annotation.Annotation)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 Map (java.util.Map)1 ServletContext (javax.servlet.ServletContext)1 Interceptor (org.axe.annotation.mvc.Interceptor)1