struts2将excel文件内容导入数据库 ----- POI

Struts2 数据导入导出 使用Struts2 结合POI 完成Excel 文件的数据导入导出 1. 导入 Excel 数据                在web 应用中需要将excel 文件中的数据导入到系统,保存到数据库中。其思路就       是把excel 文件(*.xls或者*.xls 阅读详情

原理: 先将文件导入,再读取文件内容,提取数据,生成对象,保存到数据库。

jar包:POI中poi-3.9-20121203.jar,poi-ooxml-3.9-20121203.jar这两个个为必须。实验结果。

           xbean.jar必须。

在导入的基础上操作:

public String uploadFile(){
	String directory = "/upload";  
        String targetDirectory = ServletActionContext.getServletContext().getRealPath(directory);  
        //生成上传的文件对象  
        File target = new File(targetDirectory,uploadFileFileName);  
        //如果文件已经存在,则删除原有文件  
        if(target.exists()){  
            target.delete();  
        }  
        //复制file对象,实现上传  
        try {  
            FileUtils.copyFile(uploadFile, target);  
        } catch (IOException e) {  
            e.printStackTrace();  
        }
        //从导入的文件中读取数据
        loadUserInfo(uploadFileFileName);  
	return SUCCESS;
}
private void loadUserInfo(String uploadFileFileName) {
        //读取刚才上传文件,确保路径相同
        String directory = "/upload";
        String targetDirectory = ServletActionContext.getServletContext().getRealPath(directory);
        File target = new File(targetDirectory,uploadFileFileName);
        // HSSFWorkbook只能用来读取2003前(含)的版本, .xls  读取Excel2007时发生如下异常:
                 org.apache.poi.poifs.filesystem.OfficeXmlFileException: The supplied data appears to be in the Office 2007+ XML. 
                      You are calling the part of POI that deals with OLE2 Office Documents. 
                      You need to call a different part of POI to process this data (eg XSSF instead of HSSF)
        //XSSFWorkbook 只能读取2007版本 .xlsx  读取Excel2003以前(包括2003)的版本时却发生了如下新异常:
                 org.apache.poi.openxml4j.exceptions.InvalidOperationException: Can't open the specified file: '*.xls'
        
       //XSSF和HSSF虽然在不同的包里,但却引用了同一接口Workbook,可以用下面判断
        Workbook wb = null;
        try{
            FileInputStream fi = new FileInputStream(target);  
            if (uploadFileFileName.toLowerCase().endsWith("xls")) { 
                wb = new HSSFWorkbook(fi);
            }else if(uploadFileFileName.toLowerCase().endsWith("xlsx")) { 
                wb = new XSSFWorkbook(fi);
            } 

            Sheet sheet = wb.getSheetAt(0);  
              
            int rowNum = sheet.getLastRowNum()+1;  
            userList = new ArrayList<User>();
            //i 从1开始表示第一行为标题 不包含在数据中
            for(int i=1;i<rowNum;i++){
                user = new User();
                Row row = sheet.getRow(i);  
                int cellNum = row.getLastCellNum();  
                for(int j=0;j<cellNum;j++){  
                    Cell cell = row.getCell(j);  
                    String cellValue = null;  
                    switch(cell.getCellType()){ //判断excel单元格内容的格式,并对其进行转换,以便插入数据库  
                        case 0 : cellValue = String.valueOf((int)cell.getNumericCellValue()); break;  
                        case 1 : cellValue = cell.getStringCellValue(); break;  
                        case 2 : cellValue = String.valueOf(cell.getDateCellValue()); break;  
                        case 3 : cellValue = ""; break;  
                        case 4 : cellValue = String.valueOf(cell.getBooleanCellValue()); break;  
                        case 5 : cellValue = String.valueOf(cell.getErrorCellValue()); break;  
                    }  
                      
                    switch(j){//通过列数来判断对应插如的字段  
                        //数据中不应该保护ID这样的主键记录                      
                        //case 0 : user.setId(Integer.valueOf(cellValue));break;  
                        case 0 : user.setUserName(cellValue);break;  
                        case 1 : user.setPassword(cellValue);break;  
                        case 2 : user.setFirstName(cellValue);break;
                        case 3 : user.setLastName(cellValue);break;
                        case 4 : user.setAddress(cellValue);break;
                    }  
                }  
                userList.add(user);
            } 
            userIntoDB(userList); 
        }catch(IOException e){  
            e.printStackTrace();
        }  
    }

    private void userIntoDB(List<User> userList) {
        // TODO Auto-generated method stub
        int num = userList.size();
        for(int i=0; i<num; i++){
            userService.add(userList.get(i));
        }
    }


基于struts2的导入excel文件到数据库操作 我们在做一些人员管理系统的时候,市场面临这样一个问题:信息量过大,一个一个的导入相当的费时、费力,直接选中要导入的人员信息的excel表显然是一个好方法。 addStudents.jsp 请选择要导入的excel文件:     StudentAction public String addStudents() throws Exception {     // 获取re 阅读详情

相关推荐

struts2 Excel导入数据库

poi struts2 Excel导入数据库 用jdbc连的sql server2000 非常简单 一看就能明白怎么个回事 就一张表 3个字段 适合第一次用poi的朋友

Struts2+poi实现Excel文件上传并插入数据库的操作

Struts.xml部分<package name="com.bjpowernode.crm.workbench.activity" namespace="/activity" extends="struts-default,json-default"> <action name="uploadMarkActive" class="com.bjpowernode.crm.workbench.acti

BrotherBaby的博客 5467

Struts2+poi 实现从数据库中导出excel表

Struts2 poi 实现从数据库中导出excel表

struts2中使用poi导入excel数据

public String execute() throws Exception { // 第一步 使用文件输入流 读取 xls文件 InputStream inp = new FileInputStream(upload); // 第二步 获得文档对象 POIFSFileSystem fileSystem = new POIFSFileSystem(inp); HSSFWorkbook

yzzsjyu的专栏 1346

eclipse和mysql+strust2实现excel数据的导入导出完整代码

最近在学习,所里就做了excel对数据的导入导出功能,希望对大家的学习有点用,本人所使用的开发工具是eclipse+mysql+strust,

java struts 把数据导入excel

java struts 把数据导入 excel java struts 把数据导入 excel java struts 把数据导入 excel

struts2 excel导入数据到数据库中去

实现excel导入 需要加入相关jar包: poi-3.15-beta1.jar.jar poi-examples-3.15-beta1.jar poi-excelant-3.15-beta1.jar poi-ooxml-3.15-beta1.jar poi-ooxml-schemas-3.15-beta1.jar poi-scratchpad-3.15-beta1.jar 导入ex...

baidu_37366055的博客 833

struts2+poi实现excel文件的导出

struts2+poi实现excel文件的导出,虽然有很多jxl库实现的方案,而本方案是使用struts2 mvc, apache poi库实现excel的导入导出,文档很详细

Struts2 excel 导入 数据库

项目上用到过的导入excel模块,记录下主要操作步骤以便以后查看: 首先文件上传用到commons-io-1.3.2.jar和commons-fileupload-1.2.1.jar两个包,引入。 1)点击导入按钮选择要导入的文件。代码如下:  excelFile" size='1' name="excelFile" type="file"   onchange="importIPlan

kebikakaxi的专栏 1万+

POI导入导出EXCEL文件.(struts 1.x and struts2.x).doc

web中使用POI导入导出EXCEL文件的例子 struts1.x的例子,struts2.x可以参考自己修改 1.action的写法 import java.io.*; import java.sql.*; import java.util.ArrayList; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.poi.hssf.usermodel.*; import org.apache.struts.action.*; import org.apache.struts.upload.FormFile; import org.apache.commons.beanutils.BeanUtils; public class Action { /**//* * 把数据库中的字段导入到Excel ,并生成Excel文档 **/ public ActionForward getDownload(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { Form fm = (Form) actionForm; // Excel 文件存放在服务器的相对路径下 String outputFile = request.getRealPath("/tmp/Excel.xls"); try { // 创建新的Excel 工作簿 HSSFWorkbook workbook = new HSSFWorkbook(); // 在Excel 工作簿中建一工作表 HSSFSheet sheet = workbook.createSheet("Sheet1"); // 设置单元格格式(文本) HSSFCellStyle cellStyle = workbook.createCellStyle(); cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("@")); // 在索引0的位置创建行(第一行) HSSFRow row = sheet.createRow((short) 0); HSSFCell cell1 = row.createCell((short) 0);// 第一列 HSSFCell cell2 = row.createCell((short) 1); HSSFCell cell3 = row.createCell((short) 2); // 定义单元格为字符串类型 cell1.setCellType(HSSFCell.CELL_TYPE_STRING); cell2.setCellType(HSSFCell.CELL_TYPE_STRING); cell3.setCellType(HSSFCell.CELL_TYPE_STRING); cell1.setEncoding(HSSFCell.ENCODING_UTF_16); cell2.setEncoding(HSSFCell.ENCODING_UTF_16); cell3.setEncoding(HSSFCell.ENCODING_UTF_16); // 在单元格中输入数据 cell1.setCellValue("姓名"); cell2.setCellValue("性别"); cell3.setCellValue("年龄"); Connection connection = session.connection(); String sql = "Select t.name, t.sex, t.age from table t where t.sex = ?"; try { PreparedStatement ps = connection.prepareStatement(sql); ps.setString(1, fm.getSex());// 传入查询条件 ResultSet rs = ps.executeQuery();// 查询结果存入rs connection.commit();// 执行SQL while (rs.next()) { //设置j行从第二行开始 int j = 1; row = sheet.createRow((short) j); //设置i列从第二列开始 for (int i = 1; i <= 3; i++) { HSSFCell cell = row.createCell((short) (i-1)); // 设置单元格格式 cell.setCellStyle(cellStyle); cell.setCellType(HSSFCell.CELL_TYPE_STRING); cell.setEncoding(HSSFCell.ENCODING_UTF_16); cell.setCellValue(rs.getString(i)); } j++; } request.setAttribute("message", "文件生成成功!"); } catch (SQLException e) { request.setAttribute("message", "创建文件失败!"); e.printStackTrace(); } // 删除路径下同名的Excel 文件 File path = new File(outputFile); path.delete(); // 新建一输出文件流 FileOutputStream fOut = new FileOutputStream(outputFile); // 把相应的Excel 工作簿存盘 workbook.write(fOut); // 操作结束,关闭文件 fOut.flush(); fOut.close(); //该处如果Excel过大会影响效率,谁有好的想法可以提出来参考(不过从页面下载完后就会清空) request.getSession().setAttribute("Download", outputFile); } catch (Exception ioexception) { request.setAttribute("message", "创建文件失败!"); return actionMapping.findForward("outJSP"); } return actionMapping.findForward("outJSP"); }

LangChain入门(二)-通过 Google 搜索并返回答案

并复制他给我们生成 api key。(博主使用了GitHub账号登录)-邮箱验证-手机号验证-订阅-api-key。Serpapi 提供了 google 搜索的 api 接口。首先需要我们到 Serpapi 官网上注册一个用户,

Good Luck 1万+

struts html标签库excle,struts2将excel文件内容导入数据库 ----- POI

原理: 先将文件导入,再读取文件内容,提取数据,生成对象,保存到数据库。jar包:POI中poi-3.9-20121203.jar,poi-ooxml-3.9-20121203.jar这两个个为必须。实验结果。xbean.jar必须。在导入的基础上操作:public String uploadFile(){String directory = "/upload";String targetDire...

weixin_32306885的博客 210

python等级考试——一级知识点汇总(不包含turtle画图)

本篇文章是针对中国电子学会青少年编程等级考试的,适合初学者以及青少年编程学习者

weixin_65350557的博客 9029

黑马程序员__struts+poi+jstl上传Excel .

------- <a href="http://www.itheima.com" target="blank">android培训</a>、<a href="http://www.itheima.com" target="blank">java培训</a>、期待与您交流! ---------- 1. 导入Excel数据 在web应用中...

weixin_30906701的博客 140

SARscape的DInSAR全流程-以西安市隋大兴唐长安城遗址为例

通过DInSAR对西安市隋大兴唐长安城遗址开展的年度周期性监测,发现成因是地质内部构造断裂带活动所导致的地面产生物理空间上的形变,而地面的沉降与抬升是直接影响城市发展与文化遗产保护最为常见的缓变型不可逆地质灾害。西安市地处汾渭断陷盆地中部,受临潼-长安断裂带影响,导致区域内构造活动较为强烈。由于早年西安市地表水资源匮乏,从上世纪50年代末开始大量开采地下水资源以满足城市人口不断扩张的需求,从而导致地下承压含水层水位急速下降,形成多个局部沉降中心(八里村、西工大、电子城等)。

2301_77687129的博客 5815

物理小白也能懂的PINN指南:用Python给神经网络注入‘物理常识‘

本文为物理小白提供了一份通俗易懂的PINN入门指南。通过生活化类比和Python实战,详细讲解了如何将物理定律作为约束注入神经网络,使其具备“物理常识”,从而在数据稀缺时也能做出符合规律的预测。文章以热传导方程为例,手把手教你从零构建物理信息神经网络。

open4的博客 349

poi导入导出数据库表数据实例

使用poi导入导出数据库表数据网上已经有很多例子了,在这里,把自己做的记录下来,方便以后使用。   首先在poi官网http://poi.apache.org/download.html下载最新版本的poi组件,然后把jar包放到web工程的lib下           先说poi导入excel数据到数据库吧,这里只支持excel2003,excel2007导入。我是这样处理的,这其实包括2个

子晓聊技术 9586

52、Power BI Desktop 数据筛选全攻略

本文全面介绍了Power BI Desktop中各类数据筛选功能的使用方法,涵盖布尔型数据筛选、高级文本筛选、Top N筛选、可视化级别、页面级别和报告级别筛选等核心操作。通过详细步骤、流程图和实际案例,帮助用户深入理解筛选器的层级关系与综合应用技巧,并提供常见问题解决方案,助力高效精准的数据分析与可视化展示。

linux6sysadmin的博客 110

struts2结合poi-3.7实现excel文件数据导入

我们也可能会实现这样的功能,将excel中的数据导入到数据库中,同样可以实现,所需的jar包以及相关文档参见我的前一篇博客:struts2结合poi-3.7实现将数据导出为excel,环境变量和框架都搭建好了,那么我们就开始吧,同样和struts2实现文件上传的方式差不多,只不过在读取到excel后,poi对excel文件有了自己的处理方式! 1、页面jsp页面: ...

weixin_33834628的博客 197

LLC谐振变换器软启动,不只是“慢启动”,还是“智能启动”

LLC谐振变换器的软启动,不只是“慢慢来”,而是要在控制时序、限流、响应速度之间精妙权衡。而数字控制,特别是用查表法或混合信号法,为实现真正的“最佳轨迹”提供了可能。✨小Tips:如果你的系统成本敏感,选择查表法准没错;如果你的设计目标是超高速响应,那就上混合信号的高配方案!

weixin_43199439的博客 691

文件信息批量导入数据库(Struts2实现文件上传,POI实现Excel文件读取并写入数据库) .

如题:文件信息的批量导入...... 项目中经常会遇到客户的一些单表信息的数据批量导入,也就是提供定制Excel表,再把Excel表中的数据提取到数据库的操作,其实实现起来很简单。以下是小菜鸟我的实现思路:   1、JSP页面+Struts2实现文件上传,把定制Excel上传到服务器指定目录下,以供读取; 2、POI读取Excel表格,把数据封装为持久化实体List 3、批量导入数据库

xiaokuang513204的专栏 5486

java项目反编译工具记录,共计6个工具

java项目反编译工具记录,共计6个工具

橙-极纪元-JJYCheng 1801

struts2导入excel

当前用于 通过java操作excel表格的工具类库 这一目的手段有两种: 1 jxl,一位日本程序员的开源类库。缺点是不能够支持Office 2003以上版本,对图片识别和处理能力仅限于PNG格式。 2 POI, Apache POI是Apache软件基金会的开放源码函式库,POI提供API给Java程序对Microsoft Office格式档案读和写的功能。功能强悍、性能稳定。相对与

daqingXiong的专栏 1338

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

struts2数据库数据读出excel poi

     上一篇分页技术是直接从程序中截出未加修改,所以给copy 改的人带来不便,下面的程序我会将程序变成一个个的小demo,方便大家修改,同样由于哥是菜鸟,有不对的地方希望大家指教。     struts2将数据库中数据读出变成excel用到了开源组织apache的poi。需要加载poi-3.0.1.jar包。       struts2.xml配置:<!DOCTY

java门徒 924

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

SSH框架下导入excel,POI解析导入MySql

最近在公司实习的一个内部项目采购平台,需求需要导入项目表,所以最近就研究了一下,在网上了找了一些例子,可能我是新手,调试了好久的,算是有回报了,写下文字记录自己的心路历程。 首先我们要在struts2下上传一个Excel,这样的例子网上很多,上传的文件的时候文件 路径可以写死在程序中,也可以利用struts 标签库搞一个出来,其中 选择文件:   这里的name属性要

学习那点事儿 1万+

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

上一篇: struts2导入excel
下一篇: struts2中文件上传路径
learnTech
博客等级 码龄14年 10粉丝 73原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值