java代码麻烦会的人标上注释,越详细越好,急!
packagecom.em.systemmanage.web.action;importjava.io.IOException;importjavax.servlet.S...
package com.em.systemmanage.web.action;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;
import com.em.bean.ExchFileForm;
import com.em.pub.XmlCreater;
import com.em.systemmanage.dao.ImportDataDao;
public class ImportDaoDataAction extends Action{
private Logger logger = Logger.getLogger(this.getClass());
private XmlCreater xmlCreater = XmlCreater.getInstance();
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
logger.debug("ImportDaoDataAction execute start!");
ExchFileForm fileForm = (ExchFileForm) form;
if(fileForm == null) {
logger.debug("nonononononono!");
}
FormFile file = fileForm.getFile();
logger.debug("111111111111");
try {
logger.debug("22222222222");
ImportDataDao dao = new ImportDataDao();
String str = dao.importInvoiceManage(file.getInputStream());
logger.debug("str=" + str);
if("1".equals(str)) {
request.setAttribute("result", "导入成功!");
} else {
request.setAttribute("result", "导入成本信息失败,请检查您上传的文件是否正确!");
}
logger.debug("str=" + str);
} catch (Exception e) {
e.printStackTrace();
request.setAttribute("result", "导入成本信息失败,请检查您上传的文件是否正确!");
}
logger.debug("importDaoDataAction execute end!");
return mapping.findForward("result");
}
} 展开
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;
import com.em.bean.ExchFileForm;
import com.em.pub.XmlCreater;
import com.em.systemmanage.dao.ImportDataDao;
public class ImportDaoDataAction extends Action{
private Logger logger = Logger.getLogger(this.getClass());
private XmlCreater xmlCreater = XmlCreater.getInstance();
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
logger.debug("ImportDaoDataAction execute start!");
ExchFileForm fileForm = (ExchFileForm) form;
if(fileForm == null) {
logger.debug("nonononononono!");
}
FormFile file = fileForm.getFile();
logger.debug("111111111111");
try {
logger.debug("22222222222");
ImportDataDao dao = new ImportDataDao();
String str = dao.importInvoiceManage(file.getInputStream());
logger.debug("str=" + str);
if("1".equals(str)) {
request.setAttribute("result", "导入成功!");
} else {
request.setAttribute("result", "导入成本信息失败,请检查您上传的文件是否正确!");
}
logger.debug("str=" + str);
} catch (Exception e) {
e.printStackTrace();
request.setAttribute("result", "导入成本信息失败,请检查您上传的文件是否正确!");
}
logger.debug("importDaoDataAction execute end!");
return mapping.findForward("result");
}
} 展开
展开全部
package com.em.systemmanage.web.action;
//导入相关的大段包
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;
import com.em.bean.ExchFileForm;
import com.em.pub.XmlCreater;
import com.em.systemmanage.dao.ImportDataDao;
//action的名字为ImportDaoAction
public class ImportDaoDataAction extends Action{
//初始化一个私有的日志类,并获取这个祥绝类的信息
private Logger logger = Logger.getLogger(this.getClass());
//初始化读取XML的类
private XmlCreater xmlCreater = XmlCreater.getInstance();
//以下为aciton工作代码
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
/谨仿姿/打印日志
logger.debug("ImportDaoDataAction execute start!");
//实例化ExchFileForm
ExchFileForm fileForm = (ExchFileForm) form;
//判断form是否为空,这里当访问页面时,struts的form类会自动加载页面上传来的信息
if(fileForm == null) {
//为空的情况下,打印nonononono!
logger.debug("nonononononono!");
}
//不为空,获取form传来的file信息
FormFile file = fileForm.getFile();
//打印出11111111
logger.debug("111111111111");
//try catch 捕获异常
try {
logger.debug("22222222222");
//实例化dao类
ImportDataDao dao = new ImportDataDao();
//使用DAO获取file的输入信息,赋值给String类型的变量str
String str = dao.importInvoiceManage(file.getInputStream());
//答应出str的值
logger.debug("str=" + str);
//若str的值等于1
if("1".equals(str)) {
//使用request保存结果result,内容为“导入成功”
request.setAttribute("result", "导入成功!");
} else {
//反之不等于1的话,保存结果result,内容为“失败”
request.setAttribute("result", "导入成本信息失败,请检查您上传的文件是否正确!");
}
//此处在次打印出str的值
logger.debug("str=" + str);
} catch (Exception e) {
//捕获异常
e.printStackTrace();
request.setAttribute("result", "导入成本信息失败,请检查您上传的文件是否正确!");
}
//打印信息"importDaoDataAction execute end!"
logger.debug("importDaoDataAction execute end!");
//返回值,这里返回result,对应的struts的config.xml里会有配置,映射到具体某个页面
return mapping.findForward("result");
}
}
//导入相关的大段包
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;
import com.em.bean.ExchFileForm;
import com.em.pub.XmlCreater;
import com.em.systemmanage.dao.ImportDataDao;
//action的名字为ImportDaoAction
public class ImportDaoDataAction extends Action{
//初始化一个私有的日志类,并获取这个祥绝类的信息
private Logger logger = Logger.getLogger(this.getClass());
//初始化读取XML的类
private XmlCreater xmlCreater = XmlCreater.getInstance();
//以下为aciton工作代码
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
/谨仿姿/打印日志
logger.debug("ImportDaoDataAction execute start!");
//实例化ExchFileForm
ExchFileForm fileForm = (ExchFileForm) form;
//判断form是否为空,这里当访问页面时,struts的form类会自动加载页面上传来的信息
if(fileForm == null) {
//为空的情况下,打印nonononono!
logger.debug("nonononononono!");
}
//不为空,获取form传来的file信息
FormFile file = fileForm.getFile();
//打印出11111111
logger.debug("111111111111");
//try catch 捕获异常
try {
logger.debug("22222222222");
//实例化dao类
ImportDataDao dao = new ImportDataDao();
//使用DAO获取file的输入信息,赋值给String类型的变量str
String str = dao.importInvoiceManage(file.getInputStream());
//答应出str的值
logger.debug("str=" + str);
//若str的值等于1
if("1".equals(str)) {
//使用request保存结果result,内容为“导入成功”
request.setAttribute("result", "导入成功!");
} else {
//反之不等于1的话,保存结果result,内容为“失败”
request.setAttribute("result", "导入成本信息失败,请检查您上传的文件是否正确!");
}
//此处在次打印出str的值
logger.debug("str=" + str);
} catch (Exception e) {
//捕获异常
e.printStackTrace();
request.setAttribute("result", "导入成本信息失败,请检查您上传的文件是否正确!");
}
//打印信息"importDaoDataAction execute end!"
logger.debug("importDaoDataAction execute end!");
//返回值,这里返回result,对应的struts的config.xml里会有配置,映射到具体某个页面
return mapping.findForward("result");
}
}
展开全部
public class ImportDaoDataAction extends Action{
private Logger logger = Logger.getLogger(this.getClass());//初始化日志类,路径 就是这个类的名字
private XmlCreater xmlCreater = XmlCreater.getInstance();//初始化读取XML的类
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
logger.debug("ImportDaoDataAction execute start!");//写日志
ExchFileForm fileForm = (ExchFileForm) form;
if(fileForm == null) {
logger.debug("nonononononono!");//同上
}
FormFile file = fileForm.getFile(); /滑燃/得到form文件 貌似
logger.debug("111111111111");
try {
logger.debug("22222222222");
ImportDataDao dao = new ImportDataDao(); //初始化 类
String str = dao.importInvoiceManage(file.getInputStream());//得到一个信神虚文件输入流
logger.debug("str=" + str);//记录日瞎信志
if("1".equals(str)) {
request.setAttribute("result", "导入成功!");
} else {
request.setAttribute("result", "导入成本信息失败,请检查您上传的文件是否正确!");
}
logger.debug("str=" + str);
} catch (Exception e) {
e.printStackTrace();
request.setAttribute("result", "导入成本信息失败,请检查您上传的文件是否正确!");
}
logger.debug("importDaoDataAction execute end!");
return mapping.findForward("result");//返回一个结果
}
} 这样写不知道你看得懂嘛。。。。
private Logger logger = Logger.getLogger(this.getClass());//初始化日志类,路径 就是这个类的名字
private XmlCreater xmlCreater = XmlCreater.getInstance();//初始化读取XML的类
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
logger.debug("ImportDaoDataAction execute start!");//写日志
ExchFileForm fileForm = (ExchFileForm) form;
if(fileForm == null) {
logger.debug("nonononononono!");//同上
}
FormFile file = fileForm.getFile(); /滑燃/得到form文件 貌似
logger.debug("111111111111");
try {
logger.debug("22222222222");
ImportDataDao dao = new ImportDataDao(); //初始化 类
String str = dao.importInvoiceManage(file.getInputStream());//得到一个信神虚文件输入流
logger.debug("str=" + str);//记录日瞎信志
if("1".equals(str)) {
request.setAttribute("result", "导入成功!");
} else {
request.setAttribute("result", "导入成本信息失败,请检查您上传的文件是否正确!");
}
logger.debug("str=" + str);
} catch (Exception e) {
e.printStackTrace();
request.setAttribute("result", "导入成本信息失败,请检查您上传的文件是否正确!");
}
logger.debug("importDaoDataAction execute end!");
return mapping.findForward("result");//返回一个结果
}
} 这样写不知道你看得懂嘛。。。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询