|
楼主 |
发表于 2016-4-22 15:56:42
|
显示全部楼层
我将原来的static构造函数删了,修改了service函数为如下代码,就解决了这个依赖类库路径导致文件存储基地址改变的问题了:
- public static JSONObject service(JSONObject params, ActionContext context) throws ServletException, IOException {
-
- HttpServletRequest request = (HttpServletRequest)context.get(ActionContext.REQUEST);
- HttpServletResponse response = (HttpServletResponse)context.get(ActionContext.RESPONSE);
-
- String baasPath = request.getSession().getServletContext().getRealPath("/") + ".." + File.separator + "..";
- docStorePath = baasPath + File.separator + "data" + File.separator + "attachmentSimple";
- File file = new File(docStorePath);
- if(!(file.exists() && file.isDirectory())){
- file.mkdirs();
- }
- docStoreDir = file;
-
- if(request.getMethod().equals("GET")){
- doGet(request, response);
- }else if(request.getMethod().equals("POST")){
- doPost(request, response);
- }
- return null;
- }
复制代码 |
|