论坛首页 Java企业应用论坛

我开发的基于JEE的Web应用软件开发和部署平台软件。支持Eclipse开发和调试。可以用于开发各类型应用系统和各行业应用软件。

浏览 77998 次
该帖已经被评为精华帖
作者 正文
   发表时间:2010-01-20  
java.wj 写道
你那个Main类,或者说Main servlet做的事情太多了,你应该专门写一个基类让我来用,他不做任何登录的判断,它只是解析客户端所请求的 xwl文件,而且这个main类里面好多都写死了没法扩展到比如我自己定义的xwl文件去
String webPath;
        String action;
        String type;
        File actionFile;
        String needLogin;
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        webPath = StringUtil.replace(getServletContext().getRealPath("/"), "\\", "/");
        bufferToRequest(request, webPath, true);
        FileUtil.saveFileToRequest(request);
        action = request.getParameter("action");
        actionFile = FileUtil.getFullFile(webPath, action);
        type = FileUtil.extractFileExt(action);
        if(actionFile == null)
            break MISSING_BLOCK_LABEL_424;
        if(type.equalsIgnoreCase("xwl"))
        {
            (new Parser(webPath, actionFile, request, response, action)).parse();
            break MISSING_BLOCK_LABEL_497;
        }
        needLogin = request.getAttribute("sys.needLogin").toString();
        if(!WebUtil.checkLogin(needLogin, request, response))
            return;
        try
        {
            if(!WebUtil.userHasRight(needLogin, actionFile, webPath, request))
            {
                response.setStatus(403);
                request.getRequestDispatcher("main?action=webbuilder/system/forbidden.xwl").forward(request, response);
                return;
            }
        }
        catch(Exception e)
        {
            throw new ServletException(e);
        }
        WebUtil.recordLog(request, action, 0);
        response.reset();
        if(StringUtil.stringInList(StringUtil.split(request.getAttribute("sys.webFile").toString(), ","), type.toLowerCase()) != -1)
        {
            boolean isMark = request.getParameter("__mark") != null;
            try
            {
                request.getRequestDispatcher(action).forward(request, response);
                if(isMark)
                    response.getWriter().print("{@ok@}");
            }
            catch(Exception e)
            {
                String exceptType;
                if(isMark)
                    exceptType = "mark";
                else
                    exceptType = request.getAttribute("sys.exceptionType").toString();
                WebUtil.recordLog(request, (new StringBuilder(String.valueOf(FileUtil.extractFileName(action)))).append(":").append(WebUtil.getShortError(request, e)).toString(), 2);
                WebUtil.showException(exceptType, e, request, response);
            }
        } else
        {
            response.setHeader("content-length", Long.toString(actionFile.length()));
            response.setHeader("content-type", "application/force-download");
            response.setHeader("Content-disposition", (new StringBuilder("attachment;filename=")).append(WebUtil.getFileName(actionFile.getName())).toString());
            FileInputStream inputStream = new FileInputStream(actionFile);
            SysUtil.inputStreamToOutputStream(inputStream, response.getOutputStream());
            inputStream.close();
        }
        break MISSING_BLOCK_LABEL_497;
        if(StringUtil.isEmpty(request.getQueryString()))
        {
            response.sendRedirect((String)request.getAttribute("sys.portal"));
        } else
        {
            response.setStatus(404);
            request.getRequestDispatcher("main?action=webbuilder/system/invalid.xwl").forward(request, response);
        }


希望能提供一个只解析swl文件的servlet 可以让我方便的配置到web.xml中去

兄弟,main干的作用就一件事,调用parser类解析web文件,主要任务就是完成解析xwl文件。
你看代码中如果传入的action是一个xwl文件,就一句
if (type.equalsIgnoreCase("xwl"))
new Parser(webPath, actionFile, request, response, action).parse();
其它的代码为处理诸如jsp,php,aspx,html等就forward,其它格式的就形成下载等。你可以把你的jsp等放到webbuilder/application下在,在portal中能自动出来,另外可以使用webbuilder带的explorer来配置jsp等显示的名称、图标、权限等,多余的代码主要就是为非xwl格式的文件解析用。你可以试试main?action=a.xwl或main?action=b.html或main?action=c.jsp。
0 请登录后投票
   发表时间:2010-01-20  
chenjie100 写道
java.wj 写道
你那个Main类,或者说Main servlet做的事情太多了,你应该专门写一个基类让我来用,他不做任何登录的判断,它只是解析客户端所请求的 xwl文件,而且这个main类里面好多都写死了没法扩展到比如我自己定义的xwl文件去
String webPath;
        String action;
        String type;
        File actionFile;
        String needLogin;
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        webPath = StringUtil.replace(getServletContext().getRealPath("/"), "\\", "/");
        bufferToRequest(request, webPath, true);
        FileUtil.saveFileToRequest(request);
        action = request.getParameter("action");
        actionFile = FileUtil.getFullFile(webPath, action);
        type = FileUtil.extractFileExt(action);
        if(actionFile == null)
            break MISSING_BLOCK_LABEL_424;
        if(type.equalsIgnoreCase("xwl"))
        {
            (new Parser(webPath, actionFile, request, response, action)).parse();
            break MISSING_BLOCK_LABEL_497;
        }
        needLogin = request.getAttribute("sys.needLogin").toString();
        if(!WebUtil.checkLogin(needLogin, request, response))
            return;
        try
        {
            if(!WebUtil.userHasRight(needLogin, actionFile, webPath, request))
            {
                response.setStatus(403);
                request.getRequestDispatcher("main?action=webbuilder/system/forbidden.xwl").forward(request, response);
                return;
            }
        }
        catch(Exception e)
        {
            throw new ServletException(e);
        }
        WebUtil.recordLog(request, action, 0);
        response.reset();
        if(StringUtil.stringInList(StringUtil.split(request.getAttribute("sys.webFile").toString(), ","), type.toLowerCase()) != -1)
        {
            boolean isMark = request.getParameter("__mark") != null;
            try
            {
                request.getRequestDispatcher(action).forward(request, response);
                if(isMark)
                    response.getWriter().print("{@ok@}");
            }
            catch(Exception e)
            {
                String exceptType;
                if(isMark)
                    exceptType = "mark";
                else
                    exceptType = request.getAttribute("sys.exceptionType").toString();
                WebUtil.recordLog(request, (new StringBuilder(String.valueOf(FileUtil.extractFileName(action)))).append(":").append(WebUtil.getShortError(request, e)).toString(), 2);
                WebUtil.showException(exceptType, e, request, response);
            }
        } else
        {
            response.setHeader("content-length", Long.toString(actionFile.length()));
            response.setHeader("content-type", "application/force-download");
            response.setHeader("Content-disposition", (new StringBuilder("attachment;filename=")).append(WebUtil.getFileName(actionFile.getName())).toString());
            FileInputStream inputStream = new FileInputStream(actionFile);
            SysUtil.inputStreamToOutputStream(inputStream, response.getOutputStream());
            inputStream.close();
        }
        break MISSING_BLOCK_LABEL_497;
        if(StringUtil.isEmpty(request.getQueryString()))
        {
            response.sendRedirect((String)request.getAttribute("sys.portal"));
        } else
        {
            response.setStatus(404);
            request.getRequestDispatcher("main?action=webbuilder/system/invalid.xwl").forward(request, response);
        }


希望能提供一个只解析swl文件的servlet 可以让我方便的配置到web.xml中去

兄弟,main干的作用就一件事,调用parser类解析web文件,主要任务就是完成解析xwl文件。
你看代码中如果传入的action是一个xwl文件,就一句
if (type.equalsIgnoreCase("xwl"))
new Parser(webPath, actionFile, request, response, action).parse();
其它的代码为处理诸如jsp,php,aspx,html等就forward,其它格式的就形成下载等。你可以把你的jsp等放到webbuilder/application下在,在portal中能自动出来,另外可以使用webbuilder带的explorer来配置jsp等显示的名称、图标、权限等,多余的代码主要就是为非xwl格式的文件解析用。你可以试试main?action=a.xwl或main?action=b.html或main?action=c.jsp。这里登录判断是为非xwl文件,如果需要取消登录,你可设置system/main.xml下的needLogin=false,logType=none等来配置的

0 请登录后投票
   发表时间:2010-01-20  
看了说明,赞。。
安装过程出现错误“Error1606.Could not access network location 0\.”
0 请登录后投票
   发表时间:2010-01-20  
biaowen 写道
看了说明,赞。。
安装过程出现错误“Error1606.Could not access network location 0\.”

这个错误从来没遇到过啊。可能是Norton引起的InstallShield错误。具体原因你可以参考Microsoft网站的回答:
http://support.microsoft.com/kb/315352/zh-cn
0 请登录后投票
   发表时间:2010-01-20  
这个。。。。就是用xml文件来代替js对吧?在运行时会自动生成js。跟前几天看到的基本一样。所谓的可视化..只是利用绝对布局来进行布局。我觉得这还不如直接js的直接。
0 请登录后投票
   发表时间:2010-01-20  
fireflyc 写道
这个。。。。就是用xml文件来代替js对吧?在运行时会自动生成js。跟前几天看到的基本一样。所谓的可视化..只是利用绝对布局来进行布局。我觉得这还不如直接js的直接。

你仅仅是看到了点皮毛而已。
0 请登录后投票
   发表时间:2010-01-20  
难以想象这是一个人做的?要是完善了,多少人得失业?
0 请登录后投票
   发表时间:2010-01-21  
kobevaliant 写道
很强,很难想象是一个人的作品

没错,就是我一个人写的。
0 请登录后投票
   发表时间:2010-01-21  
看上去不错的。思路挺好
比较适合企业信息系统建设
0 请登录后投票
   发表时间:2010-01-22  
我看了demo之后发现这个工具不仅仅是个界面设计工具,还将sql直接做在界面里,这方面是不是有点倒退了呢?
我指望它只是个view层,可以调用比如spring ioc里的业务层对象。
0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics