Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @RestController
- @RequestMapping("/api")
- public class PwsResource {
- @RequestMapping(value = "/import-data", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity importData() throws URISyntaxException, IOException {
- ....
- if (!path.isEmpty()) {
- importService.importData(path);
- return new ResponseEntity<>(HttpStatus.OK);
- } else {
- return new ResponseEntity<>(HttpStatus.NO_CONTENT);
- }
- }
- <script type="text/javascript">
- $(document).ready(function () {
- $('#import').click(function (event) {
- $.ajax({
- url: 'api/import-data',
- data: '',
- type: "GET",
- beforeSend: function (xhr) {
- xhr.setRequestHeader("Accept", "application/json");
- xhr.setRequestHeader("Content-Type", "application/json");
- },
- success: function () {
- console.log("done")
- }
- });
- });
- });
- </script>
- server:
- port: 3000
- spring:
- profiles:
- active: live
- datasource:
- url: jdbc:mysql:/server:3306/project?autoReconnect=true
- username: root
- password: password
- server:
- contextPath: /project
- session-timeout: 28800
- spring:
- profiles:
- active: live
- view:
- prefix: /ui/
- suffix: .html
- mvc:
- locale: en_UK
- date-format: yyyy-MM-dd'T'HH:mm:ss.SSSZ
- jmx:
- enabled: false
- datasource:
- dataSourceClassName: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
- url: jdbc:mysql://server:3306/project?autoReconnect=true
- username: root
- password: password
- cachePrepStmts: true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement