Package org.g4studio.common.web

Examples of org.g4studio.common.web.BaseActionForm


    return dataList;
  }
 
  public ActionForward saveTheSubmitInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    BaseActionForm aForm = (BaseActionForm)form;
    Dto dto = aForm.getParamAsDto(request);
    System.out.println("接收到的表单提交参数:\n" + dto);
    response.setCharacterEncoding("UTF-8");
    //int i = 3/0;
    demoService.doError();
    setOkTipMsg("数据提交成功:" + dto.toString(), response);
View Full Code Here


   * @return
   * @throws Exception
   */
  public ActionForward queryFileDatas(ActionMapping mapping, ActionForm form, HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    BaseActionForm aForm = (BaseActionForm) form;
    Dto dto = aForm.getParamAsDto(request);
    List list = g4Reader.queryForPage("Demo.queryFiles", dto);
    Integer countInteger = (Integer) g4Reader.queryForObject("Demo.countFiles", dto);
    String jsonString = JsonHelper.encodeList2PageJson(list, countInteger, null);
    super.write(jsonString, response);
    return mapping.findForward(null);
View Full Code Here

   * @param
   * @return
   */
  public ActionForward doUpload(ActionMapping mapping, ActionForm form, HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    BaseActionForm cForm = (BaseActionForm) form;
    // 单个文件,如果是多个就cForm.getFile2()....支持最多5个文件
    FormFile myFile = cForm.getFile1();
    // 获取web应用根路径,也可以直接指定服务器任意盘符路径
    String savePath = getServlet().getServletContext().getRealPath("/") + "/upload/";
    // String savePath = "d:/upload/";
    // 检查路径是否存在,如果不存在则创建之
    File file = new File(savePath);
    if (!file.exists()) {
      file.mkdir();
    }
    // 文件按天归档
    savePath = savePath + G4Utils.getCurDate() + "/";
    File file1 = new File(savePath);
    if (!file1.exists()) {
      file1.mkdir();
    }
    // 文件真实文件名
    String fileName = myFile.getFileName();
    // 我们一般会根据某种命名规则对其进行重命名
    // String fileName = ;
    File fileToCreate = new File(savePath, fileName);
    // 检查同名文件是否存在,不存在则将文件流写入文件磁盘系统
    if (!fileToCreate.exists()) {
      FileOutputStream os = new FileOutputStream(fileToCreate);
      os.write(myFile.getFileData());
      os.flush();
      os.close();
    } else {
      // 此路径下已存在同名文件,是否要覆盖或给客户端提示信息由你自己决定
      FileOutputStream os = new FileOutputStream(fileToCreate);
      os.write(myFile.getFileData());
      os.flush();
      os.close();
    }
    // 我们通常还会把这个文件的相关信息持久化到数据库
    Dto inDto = cForm.getParamAsDto(request);
    inDto.put("title", G4Utils.isEmpty(inDto.getAsString("title")) ? fileName : inDto.getAsString("title"));
    inDto.put("filesize", myFile.getFileSize());
    inDto.put("path", savePath + fileName);
    demoService.doUpload(inDto);
    setOkTipMsg("文件上传成功", response);
View Full Code Here

   * @return
   * @throws Exception
   */
  public ActionForward delFiles(ActionMapping mapping, ActionForm form, HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    BaseActionForm aForm = (BaseActionForm) form;
    Dto dto = aForm.getParamAsDto(request);
    String[] strChecked = dto.getAsString("strChecked").split(",");
    for (int i = 0; i < strChecked.length; i++) {
      String fileid = strChecked[i];
      Dto fileDto = (BaseDto) g4Reader.queryForObject("Demo.queryFileByFileID", fileid);
      String path = fileDto.getAsString("path");
View Full Code Here

   * @return
   * @throws Exception
   */
  public ActionForward downloadFile(ActionMapping mapping, ActionForm form, HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    BaseActionForm aForm = (BaseActionForm) form;
    Dto dto = aForm.getParamAsDto(request);
    String fileid = dto.getAsString("fileid");
    Dto fileDto = (BaseDto) g4Reader.queryForObject("Demo.queryFileByFileID", fileid);
    // 这里可稍做优化,根据文件类型动态设置此属性
    // response.setContentType("application/vnd.ms-excel");
    String filename = G4Utils.encodeChineseDownloadFileName(request, fileDto.getAsString("title"));
View Full Code Here

   * @param
   * @return
   */
  public ActionForward doUploadBasedFlah(ActionMapping mapping, ActionForm form, HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    BaseActionForm cForm = (BaseActionForm) form;
    FormFile myFile = cForm.getSwfUploadFile();
    // 获取web应用根路径,也可以直接指定服务器任意盘符路径
    String savePath = getServlet().getServletContext().getRealPath("/") + "/upload/";
    // String savePath = "d:/upload/";
    // 检查路径是否存在,如果不存在则创建之
    File file = new File(savePath);
    if (!file.exists()) {
      file.mkdir();
    }
    // 文件按天归档
    savePath = savePath + G4Utils.getCurDate() + "/";
    File file1 = new File(savePath);
    if (!file1.exists()) {
      file1.mkdir();
    }
    // 文件真实文件名
    String fileName = myFile.getFileName();
    // 我们一般会根据某种命名规则对其进行重命名
    // String fileName = ;
    File fileToCreate = new File(savePath, fileName);
    // 检查同名文件是否存在,不存在则将文件流写入文件磁盘系统
    if (!fileToCreate.exists()) {
      FileOutputStream os = new FileOutputStream(fileToCreate);
      os.write(myFile.getFileData());
      os.flush();
      os.close();
    } else {
      // 此路径下已存在同名文件,是否要覆盖或给客户端提示信息由你自己决定
      FileOutputStream os = new FileOutputStream(fileToCreate);
      os.write(myFile.getFileData());
      os.flush();
      os.close();
    }
    // 我们通常还会把这个文件的相关信息持久化到数据库
    Dto inDto = cForm.getParamAsDto(request);
    inDto.put("title", G4Utils.isEmpty(inDto.getAsString("title")) ? fileName : inDto.getAsString("title"));
    inDto.put("filesize", myFile.getFileSize());
    inDto.put("path", savePath + fileName);
    demoService.doUpload(inDto);
    setOkTipMsg("文件上传成功", response);
View Full Code Here

   * @return
   * @throws Exception
   */
  public ActionForward queryAreas(ActionMapping mapping, ActionForm form, HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    BaseActionForm aForm = (BaseActionForm)form;
    Dto dto = new BaseDto();
    String areacode = aForm.getTreeNodeUID4Clicked(request);
    dto.put("areacode", areacode);
    dto.put("length", areacode.length() + 2);
    List list = null;
    if (areacode.equals("00")) {
      list = g4Reader.queryForList("Demo.queryAreas4Tree4FirstLevel", dto);
View Full Code Here

   * @return
   * @throws Exception
   */
  public ActionForward queryAreas4CheckTree(ActionMapping mapping, ActionForm form, HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    BaseActionForm aForm = (BaseActionForm)form;
    Dto dto = new BaseDto();
    String areacode = aForm.getTreeNodeUID4Clicked(request);
    dto.put("areacode", areacode);
    dto.put("length", areacode.length() + 2);
    List list = null;
    if (areacode.equals("00")) {
      list = g4Reader.queryForList("Demo.queryAreas4Tree4FirstLevel", dto);
View Full Code Here

   * @return
   * @throws Exception
   */
  public ActionForward queryAreas4CheckTree2(ActionMapping mapping, ActionForm form, HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    BaseActionForm aForm = (BaseActionForm)form;
    Dto dto = new BaseDto();
    String areacode = aForm.getTreeNodeUID4Clicked(request);
    dto.put("areacode", areacode);
    dto.put("length", areacode.length() + 2);
    List list = null;
    if (areacode.equals("00")) {
      list = g4Reader.queryForList("Demo.queryAreas4Tree4FirstLevel", dto);
View Full Code Here

   * @param
   * @return
   */
  public ActionForward synMemory(ActionMapping mapping, ActionForm form, HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    BaseActionForm aForm = (BaseActionForm) form;
    List codeList = g4Reader.queryForList("Resource.getCodeViewList");
    getServlet().getServletContext().removeAttribute("EACODELIST");
    getServlet().getServletContext().setAttribute("EACODELIST", codeList);
    setOkTipMsg("内存同步成功", response);
    return mapping.findForward(null);
View Full Code Here

TOP

Related Classes of org.g4studio.common.web.BaseActionForm

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.