1,在根目录下,在Navigator视图中创建,可以直接用文件夹,比较简单
eg: dw_cms项目中,
dw_cms-->src-->cn.com.dwsoft中,创建一个Folder文件夹,选好附属的路径
- 然后在new下,接着创建三个文件夹Folder。分别命名为action,dao,service
- 在action层下,创建class,在dao,service层里创建impl文件夹,用来写实现类,再在impl 文件夹里创建class类。dao,service层下创建class类,用来做接口类。
- 拿fileImport项目举例:
- action层: (1)写包名:
package cn.com.dwsoft.fileImport.action;
(2)引包名:以下是我的例子,可以用ctrl+shift+r
import java.io.File;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import net.sf.json.JSONObject;
import cn.com.dwsoft.common.action.DwsoftActionSupport;
import cn.com.dwsoft.common.config.ConfigFactory;
import cn.com.dwsoft.common.config.IConfig;
import cn.com.dwsoft.common.data.PageResult;
import cn.com.dwsoft.common.exception.ConfigException;
import cn.com.dwsoft.common.logging.Log;
import cn.com.dwsoft.common.logging.LogFactory;
import cn.com.dwsoft.common.support.DwsoftConstants;
import cn.com.dwsoft.common.utils.DownLoadFileUtil;
import cn.com.dwsoft.common.utils.HSSFConfig;
import cn.com.dwsoft.common.utils.HSSFCreate;
import cn.com.dwsoft.fileImport.service.ExternalFileImportService;
(3)将自己新建的类继承给已有的封装好的类里。这里通常是DwsoftActionSupport
public class ExternalFileImportAction extends DwsoftActionSupport{
(4)action层传给service接口层--》serviceimp实现类。--》dao接口层--》dao实现层
6 . service接口层:
(1)引包
package cn.com.dwsoft.fileImport.service;
(2)接口 public interface + 自己的service接口层的名字
public interface ExternalFileImportService {
/**
*
* 上传文件
* @Title: uploadFile
* @see
*/
public String uploadFile(File file,Map<String, String> param) throws Exception;
/**
*
* 加载数据
* @Title: loadData
* @see
*/
serviceimpl 实现层:
(1)引包
package cn.com.dwsoft.fileImport.service.impl;
(2)实现层的继承 public class + 实现层的impl名字 implements + service接口层的名字
@Service
public class ExternalFileImportServiceImpl implements ExternalFileImportService {
7. dao 接口层:
(1)引包
package cn.com.dwsoft.fileImport.dao;
(2)接口 public interface + dao层接口类
public interface ExternalFileImportDao {
/**
* 保存数据到数据源表
* @Title: saveDsInfo
* @see
*/
public void saveDsInfo(Map<String,Object> info,String tabName) throws Exception;
dao实现层:
(1)引包
package cn.com.dwsoft.fileImport.dao.impl;
(2)实现层的继承 public class + 实现层的daoimp名字 implements + dao接口层的名字
@Service
public class ExternalFileImportDaoImpl implements ExternalFileImportDao {
@Resource
private DwsoftJdbcDaoSupport jdbcDaoSupport;
private Log logger = LogFactory.getLog(getClass());
8.web层
在webRoot目录下,创建文件夹file_import,分别创建一个jsp,js文件
(1)web->下的 jsp File文件 jsp文件
编写:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="/report_configure/report_head.jsp"%>
<%
String str="";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<script>
var basePath='<%=basePath%>';
</script>
<script type="text/javascript" src='<%=basePath%>/user_manage/js/user_manage.js'></script>
<title>Insert title here</title>
</head>
<body>
</body>
</html>
(2) 创建js文件 JavaScript 下的JavaScript Source File