Showing
2 changed files
with
79 additions
and
78 deletions
@@ -68,7 +68,8 @@ public class SpecialController { | @@ -68,7 +68,8 @@ public class SpecialController { | ||
68 | * @param | 68 | * @param |
69 | * @return | 69 | * @return |
70 | */ | 70 | */ |
71 | - @RequestMapping(params = "method=getStyleListSel") | 71 | +// @RequestMapping(params = "method=getStyleListSel") |
72 | + @RequestMapping(params = "/getStyleListSel") | ||
72 | @ResponseBody | 73 | @ResponseBody |
73 | public JSONArray getStyleListSel(EnumTypeRequestBean enumTypeRequestBean) { | 74 | public JSONArray getStyleListSel(EnumTypeRequestBean enumTypeRequestBean) { |
74 | logger.info("begin getStyleListSel"); | 75 | logger.info("begin getStyleListSel"); |
@@ -149,80 +150,80 @@ public class SpecialController { | @@ -149,80 +150,80 @@ public class SpecialController { | ||
149 | } | 150 | } |
150 | } | 151 | } |
151 | 152 | ||
152 | - /** | ||
153 | - * 导出表格的excel表格 | ||
154 | - * | ||
155 | - * @param param 批量导出的业务类型 | ||
156 | - * @return | ||
157 | - */ | ||
158 | - @RequestMapping(value = "/export") | ||
159 | - public String export(HttpServletResponse response, @RequestBody ExportParam param) { | ||
160 | - File file; | ||
161 | - try { | ||
162 | - file = batchService.batchExport(param); | ||
163 | - } catch (PlatformException e) { | ||
164 | - logger.warn("export find wrong.", e); | ||
165 | - return writeErrorInfo(response, e.getMessage()); | ||
166 | - } catch (Exception e) { | ||
167 | - logger.warn("export find wrong.", e); | ||
168 | - return writeErrorInfo(response, "<p>导出记录条数太多</p>"); | ||
169 | - } | ||
170 | - try { | ||
171 | - return writeFile(response, file.getName(), new FileInputStream(file), "application/vnd.ms-excel"); | ||
172 | - } catch (FileNotFoundException e) { | ||
173 | - | ||
174 | - logger.warn("writeFile find wrong.", e);; | ||
175 | - return writeErrorInfo(response, "文件不存在"); | ||
176 | - } | ||
177 | - } | ||
178 | - | ||
179 | - private String writeErrorInfo(HttpServletResponse response, String string) { | ||
180 | - PrintWriter printWriter = null; | ||
181 | - response.setHeader("Content-type", "text/html;charset=UTF-8"); | ||
182 | - response.setCharacterEncoding("UTF-8"); | ||
183 | - try { | ||
184 | - printWriter = response.getWriter(); | ||
185 | - printWriter.print(new String(string.getBytes("UTF-8"), "UTF-8")); | ||
186 | - printWriter.flush(); | ||
187 | - } catch (IOException e) { | ||
188 | - logger.warn("OS.write find wrong.", e); | ||
189 | - } finally { | ||
190 | - if (null != printWriter) { | ||
191 | - try { | ||
192 | - printWriter.close(); | ||
193 | - } catch (Exception e) { | ||
194 | - logger.warn("OS.close find wrong.", e); | ||
195 | - } | ||
196 | - } | ||
197 | - } | ||
198 | - return null; | ||
199 | - } | ||
200 | - | ||
201 | - /** | ||
202 | - * 向 response 中,写入文件 | ||
203 | - */ | ||
204 | - private String writeFile(HttpServletResponse response, String fileName, InputStream inputStream, String contentType) { | ||
205 | - checkNotNull(inputStream, "inputStream is null!"); | ||
206 | - String msg = null; | ||
207 | - response.setCharacterEncoding("utf-8"); | ||
208 | - response.setContentType(contentType); | ||
209 | - response.setHeader("Content-Disposition", "attachment;fileName=" + fileName); | ||
210 | - try { | ||
211 | - byte[] b = new byte[2048]; | ||
212 | - int length; | ||
213 | - OutputStream os = response.getOutputStream(); | ||
214 | - while ((length = inputStream.read(b)) > 0) { | ||
215 | - os.write(b, 0, length); | ||
216 | - } | ||
217 | - os.close(); | ||
218 | - inputStream.close(); | ||
219 | - } catch (FileNotFoundException e) { | ||
220 | - e.printStackTrace(); | ||
221 | - msg = "File not found"; | ||
222 | - } catch (IOException e) { | ||
223 | - e.printStackTrace(); | ||
224 | - msg = "Read file error"; | ||
225 | - } | ||
226 | - return msg; | ||
227 | - } | 153 | +// /** |
154 | +// * 导出表格的excel表格 | ||
155 | +// * | ||
156 | +// * @param param 批量导出的业务类型 | ||
157 | +// * @return | ||
158 | +// */ | ||
159 | +// @RequestMapping(value = "/export") | ||
160 | +// public String export(HttpServletResponse response, @RequestBody ExportParam param) { | ||
161 | +// File file; | ||
162 | +// try { | ||
163 | +// file = batchService.batchExport(param); | ||
164 | +// } catch (PlatformException e) { | ||
165 | +// logger.warn("export find wrong.", e); | ||
166 | +// return writeErrorInfo(response, e.getMessage()); | ||
167 | +// } catch (Exception e) { | ||
168 | +// logger.warn("export find wrong.", e); | ||
169 | +// return writeErrorInfo(response, "<p>导出记录条数太多</p>"); | ||
170 | +// } | ||
171 | +// try { | ||
172 | +// return writeFile(response, file.getName(), new FileInputStream(file), "application/vnd.ms-excel"); | ||
173 | +// } catch (FileNotFoundException e) { | ||
174 | +// | ||
175 | +// logger.warn("writeFile find wrong.", e);; | ||
176 | +// return writeErrorInfo(response, "文件不存在"); | ||
177 | +// } | ||
178 | +// } | ||
179 | +// | ||
180 | +// private String writeErrorInfo(HttpServletResponse response, String string) { | ||
181 | +// PrintWriter printWriter = null; | ||
182 | +// response.setHeader("Content-type", "text/html;charset=UTF-8"); | ||
183 | +// response.setCharacterEncoding("UTF-8"); | ||
184 | +// try { | ||
185 | +// printWriter = response.getWriter(); | ||
186 | +// printWriter.print(new String(string.getBytes("UTF-8"), "UTF-8")); | ||
187 | +// printWriter.flush(); | ||
188 | +// } catch (IOException e) { | ||
189 | +// logger.warn("OS.write find wrong.", e); | ||
190 | +// } finally { | ||
191 | +// if (null != printWriter) { | ||
192 | +// try { | ||
193 | +// printWriter.close(); | ||
194 | +// } catch (Exception e) { | ||
195 | +// logger.warn("OS.close find wrong.", e); | ||
196 | +// } | ||
197 | +// } | ||
198 | +// } | ||
199 | +// return null; | ||
200 | +// } | ||
201 | +// | ||
202 | +// /** | ||
203 | +// * 向 response 中,写入文件 | ||
204 | +// */ | ||
205 | +// private String writeFile(HttpServletResponse response, String fileName, InputStream inputStream, String contentType) { | ||
206 | +// checkNotNull(inputStream, "inputStream is null!"); | ||
207 | +// String msg = null; | ||
208 | +// response.setCharacterEncoding("utf-8"); | ||
209 | +// response.setContentType(contentType); | ||
210 | +// response.setHeader("Content-Disposition", "attachment;fileName=" + fileName); | ||
211 | +// try { | ||
212 | +// byte[] b = new byte[2048]; | ||
213 | +// int length; | ||
214 | +// OutputStream os = response.getOutputStream(); | ||
215 | +// while ((length = inputStream.read(b)) > 0) { | ||
216 | +// os.write(b, 0, length); | ||
217 | +// } | ||
218 | +// os.close(); | ||
219 | +// inputStream.close(); | ||
220 | +// } catch (FileNotFoundException e) { | ||
221 | +// e.printStackTrace(); | ||
222 | +// msg = "File not found"; | ||
223 | +// } catch (IOException e) { | ||
224 | +// e.printStackTrace(); | ||
225 | +// msg = "Read file error"; | ||
226 | +// } | ||
227 | +// return msg; | ||
228 | +// } | ||
228 | } | 229 | } |
-
Please register or login to post a comment