简体   繁体   中英

How to return xls excel file response using REST API controller in weburl

I need to return x ls excel file in response using Rest API controller in web URL in spring i am not getting data from Database just setting fix value now i have written controller part and service manager part but i am finding the following errors:

in console :

expected at least 1 bean which qualifies as autowire candidate.

and in browser:

Firefox can't establish a connection to the server at localhost:8080.

code for controller :

 @RestController
 @RequestMapping(value = "/excel")
 public class ExcelController {

    @CrossOrigin(origins = "*")

    catch (Exception e) {

    }
    return null;

 }

Your ExcelManager is not declared as a bean. You need either add @Service above your ExcelManager class definition, or declare it in applicationContext.xml

You have to annotate your service class with the annotation @Service . Otherwise Spring will not be able to autowire it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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