简体   繁体   English

从xlsx文件读取数据的代码应放在Web项目中的什么位置?

[英]Where should the code to read data from an xlsx file be placed in a web project?

I have a web project which has the same as in a typical web project, say web, dto, service, dao. 我有一个与典型Web项目相同的Web项目,例如web,dto,service,dao。 Now I'm working with the service layer. 现在,我正在使用服务层。 Now, I want to read an xls file and each row should be pushed to the db via dao. 现在,我想读取一个xls文件,每一行都应通过dao推送到db。 I have created a separate utility class to read the xls file. 我创建了一个单独的实用程序类来读取xls文件。 To which layer, the logic of reading should go? 阅读的逻辑应该走到哪一层? Should it be kept in the web itself and after reading it from the web, a list should be created and passed on to the service layer? 是否应将其保存在Web本身中,并在从Web读取后将其列表创建并传递到服务层? Is this approach correct? 这种方法正确吗? Any advice? 有什么建议吗?

Having the logic of reading the excel file in the service layer is fine. 具有在服务层中读取excel文件的逻辑很好。 I am assuming that the excel file will be received when a user uploads a file in the web app. 我假设当用户在Web应用程序中上传文件时将接收excel文件。 If you have a controller, then delegate the reading of the excel file to the service from the controller and then delegate the persistence to the dao layer. 如果您有控制器,则将对excel文件的读取委托给来自控制器的服务,然后将持久性委托给dao层。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM