Questions tagged [spring]

The Java platform is empowered by the Spring Framework, an open-source framework designed for application development. This robust framework excels in supporting component-based architectures and boasts a diverse collection of more than twenty seamlessly integrated modules.

Is it possible to create a mapping for the jsonProperty of nested fields in an object?

In my project, I have created two classes named Car.java and Bus.java. Car.java private Property property; Bus.java private Property property; The Property.java class contains attributes for number and colour. ...

Is there a way to transform the XML output from Roku TV's API into JSON format?

I've been working on developing an application that interacts with the Roku TV ECP API commands. One specific call I'm attempting to make retrieves a list of all installed channels and returns it in XML format. However, every time I make this API call, I e ...

Problem with JSON in Spring Boot REST API

Within my spring boot rest application, there is a controller containing the method below. This method utilizes hibernate to retrieve data from an Oracle DB. The problem arises when I call this service, as it returns a HTTP ERROR 500. Strangely, no error ...

Receiving an initialized object rather than the expected response from the service

When using the POST method to send an object as a parameter to a service method, I am encountering an issue where Spring is returning an initialized object (with zeros and nulls) instead of the expected result. Interestingly, everything works perfectly fi ...

Encountered an error while attempting to retrieve JSON data: Unknown attribute detected - "_links". A problem was encountered while utilizing an Android REST HATE

I was following a tutorial on Android REST client from spring.io, specifically the one available at this link. However, instead of using the greeting service as described in the tutorial, I decided to implement my own REST HATEOAS service. My service retur ...

What is the method for editing individual rows in a data table in Spring MVC when the edit button is clicked?

Every time I click on <a id="myBtn"><i class="fa fa-pencil" style="color:OliveDrab;"></i></a>, I only get a modal on the first row click, and it appears empty. I've searched through many internet resources, but none of them provided ...

org.openqa.selenium.WebDriverException: The driver server startup timed out. Version information: version: 'unknown', revision: 'unknown'

Despite everything functioning correctly on my local machine, issues arise when I transfer the project to my server. Selenium and Chromedriver fail to boot, resulting in the error below: 2018-08-31 09:16:06,578 ERROR [stderr] (Exec Stream Pumper) /home/ap ...

Discovering if an email is already registered using AngularJS and Spring Boot

After some careful consideration, I believe I am close to resolving my issue but I still require a little bit of fine-tuning. Within my @RestController, I have implemented the following code snippet to verify the existence of a user: @RequestMapping(valu ...

What is the best way to pass a JSP variable to a ReactJS file?

I'm currently working on a project that involves using the spring framework and React.js. In one of my JSP files, I have a ${variable} that has been injected. However, I'm having trouble passing this variable to my React.js file. I tried writing ...

Ajax - Is utilizing API Endpoints the correct approach?

I am encountering an encoding issue when making an AJAX request to an API Endpoint. The code snippet below shows the Endpoint implementation using Java Spring: @Autowired ApiKeyRepository apiKeyRepository; @RequestMapping(value= "/weather/{cit ...

What is the most effective way to retrieve the JSON body as is in Java?

My goal is to retrieve JSON input with field names enclosed in double quotes. However, when I attempt to display it on the screen, the double quotes are missing. This is required for input into a PL/SQL CLOB. Below is the code snippet: @POST @Produces(val ...

The latest version of Spring MVC, 4.1.x, is encountering a "Not Acceptable" error while trying

After creating a Rest Service using Spring MVC4.1.X, I encountered an issue when attempting to return Json output to the browser. The error message displayed was: The resource identified by this request is only capable of generating responses with charact ...

Utilizing dynamic JSON lists in Spring MVC

Currently, I have a new form for Person that includes a table of objects structured like so: <table class="table table-striped table-condensed flip-content"> <thead class="flip-content"> <tr> <th width="20%"> ...

The response from the ajax call is still pending

I am currently working on integrating MySQL data (select query) using Spring and MyBatis. I have a controller function that is called via ajax in JavaScript to retrieve the database data. For example: ajax url: /testmysql controller requestmapp ...

While utilizing Ajax with Spring, it is possible to send a JavaScript object and receive it as a custom object. However, there was an issue with

One of my challenges in Java is working with a custom class that looks like this: public class AddressesVO { private Long addressId; private String address; public Long getAddressId() { return addressId; } public void setAddressId(Long addressId ...

Sending a parameter to the window.onload callback function

Is there a way to pass parameters from ModelAndView to a window.onload function in JavaScript within an HTML file? Here is an example of how it can be done: @RequestMapping(value = "/admin/printtext") public ModelAndView printtext() { ModelAndView mo ...

Tips for modifying the JSON format within a Spring and Angular project

I am utilizing Spring for the backend and Angular for the frontend. Below is my REST code: @GetMapping(path = "/endpoint") public @ResponseBody Iterable<Relations> getGraphGivenEndpointId(@RequestParam(value = "id") int id) { return ...

Discover an Effective Approach for Transmitting Form-Data as a JSON Object

Hey there! I'm encountering a bit of an issue with sending some data as a JSON object. The problem arises when trying to send images using FormData. It seems like I need to convert my form data into a single JSON object. Can anyone assist me with this? Tha ...

What is the proper way to send a HTTP status code 409 (conflict) and a JSON response from a spring REST API when a duplicate email is detected while a user is registering

I have attempted a few solutions so far, including: Using the Response object, but I prefer to avoid utilizing the servlet API of JSP. Trying a solution that returns an HTML response with a status code, however, I need it to be JSON instead. Here is a ...

Transmitting JSON and FormData between Angular and Spring

Angular Tutorial processRegistration(user: any, file: File): Observable<any>{ let formData = new FormData(); formData.append("user", JSON.stringify({username:'User'})); formData.append("file", file); return this.http.post( ...

What steps should be taken to manage expired sessions with the combination of spring-security and jQuery?

In my application, I am utilizing spring-security and jQuery. The main page loads content dynamically into tabs through Ajax. Everything seems to be functioning correctly, but occasionally the login page pops up inside one of the tabs. When I enter my cred ...

Launching an Angular JS application with a Java Spring backend on a standalone Tomcat server

Utilizing Intellij IDE, I developed a Java Spring and AngularJS application. After creating a war (Web Application:Exploded) file in Intellij, I placed it in the Tomcat webapps directory. Although the AngularJS code deployed successfully and was accessible ...

Nginx deployment of React causes issues with AJAX Axios functionality

I am interested in integrating frontend with backend on cloud virtual machines such as DigitalOcean, AWS, or Microsoft Azure. Frontend: React Backend: Spring Spring MVC Mybatis + Tomcat (Excluding Spring Boot) After researching various methods using N ...

Displaying the contents of an ArrayList in a Spring Boot application

After creating an ArrayList with the JSON values from a Rest API, I encountered the following code to read the Rest API: @RestController public class exemploclass { @RequestMapping(value="/vectors") ...

The spring controller sends back an empty Ajax response, despite successfully completing the request

The data received from the Spring controller appears to be empty when passed to the AJAX success function. To troubleshoot, I attempted returning a string directly from the controller like so: @ResponseBody @RequestMapping(value = "/test", method = Reque ...

Is it possible to seamlessly alternate between JSON using the Jackson processor and XML using XStream, or is it feasible to use both formats simultaneously

I am in the process of developing a Web Server that can convert an Object into both JSON and XML formats. I have successfully used Jackson to serialize an object into JSON through my REST Interface, but I also need to support XML serialization. Recently, ...

Retrieving specific information from the Model and returning it as a JSON response using annotations

I am interested in receiving a JSON response with additional annotations. Currently, my JSON response looks like: { "id": 1, "startDate": [ 1993, 12, 12 ], "endDate": [ 2018, 11, 22 ], "totalDistance": 255, "totalPrice": 211 } How ...

Using the Angular two-way binding tag within a Spring Boot Thymeleaf application allows for seamless data synchronization between

I have a JSON file where my image is defined like this certLogoURL : "/img/ocjp.gif" I am attempting to show this image in my Thymeleaf template using the following code: <img th:src="@{ {{certificate.certLogoURL}} }" > </img> However, the ...

Creating a JSON parameterized Spring REST webservice that can be easily consumed through Jquery AJAX

I am currently in the process of learning the Spring Framework in order to develop RESTful web services for my upcoming projects. So far, I have successfully utilized the GET method and consumed data through a simple Ajax request. Additionally, I have expe ...

Retrieve data from multiple inputs with the same name in a Spring MVC form

I have a JSP page with input fields that can be dynamically added or removed. I need to map these input fields to the @ModelAttributes in Spring MVC, but I'm unsure of how to do this. I want to submit a form that includes: <form enctype="multipart/for ...

The preflight response is denying the request header field ack, despite the server permitting it

This question has been circulating on various platforms, but this one is a bit unique. I encountered an error while attempting to access a Java API using axios with the following code: axios .get("http://127.0.0.1:8090/api/v1/homescreen") .the ...

Protect an API with React utilizing CAS (Centralized Authentication Service) for front end sign in and Spring Boot for backend and making Rest API requests

Currently, I have successfully implemented CAS to secure the frontend of my React app using the package found here: https://www.npmjs.com/package/react-cas-client Now my aim is to secure the backend as well and restrict access to API calls from the app by ...

The requested URI SpringRestfulWebServicesWithJSONExample does not have a corresponding mapping in the HTTP request

I am facing an issue with the JSON example provided on this website: . Despite following all the instructions correctly, whenever I use Tomcat, a log message appears: November 11, 2015 5:09:52 PM org.springframework.web.servlet.PageNotFound noHandlerFou ...

Addressing the data transfer issue between Spring framework and Next.js using Axios

For my upcoming project, I am considering using a combination of Spring and Next.js. In the past, I have worked on projects using Spring and React. I find the API/route structure in Next.js 13 version to be quite intriguing compared to traditional React ...

Encountering an issue when trying to upload a file: Spring 4 and Angular JS throwing error stating that the current request is not a

Currently, I am utilizing Spring 4 along with AngularJS. To handle multipart requests, I have included commons-fileupload-1.3.2.jar and commons-io-2.4.jar in my project. However, I encountered an error stating "org.springframework.web.multipart.MultipartEx ...

Create RESTful routes based on the attributes of the resource

When dealing with a User entity and needing to retrieve its data using different criteria or routes, such as by id or username, what is the recommended approach for naming these specific endpoints: GET /users/:id GET /users/username/:username GET /users/ ...

Altering the names of fields in a REST API's response

Greetings! As a newcomer, I might not grasp advanced solutions right away. Let's get to the point: I need to send a response for a REST API. Essentially, what's happening is that I return an object from a method and then the fields of those obje ...

Storing JSON data in a concealed field and extracting it for use in a function

I have a function that retrieves the number of rows from a database table using JSON in my application. function getRowCount() { $.ajax({ headers: { 'Accept': 'application/json', 'Conte ...

Enhancing Spring REST for optimal JSON integration with lists and objects

Can Spring support this JSON without creating a new object in Java? Perhaps using a Map? JSON: { "object":"1", "list":[ { "id":"1" } ] } Java: @RequestMapping(method = RequestMethod ...

Exploring the world of Spring MVC: Utilizing partial view fragments

I've recently started working with Spring MVC on a new project and I'm doing some research to ensure it's set up properly for long-term success. One aspect of the project will require me to manually update small sections of the page using Ajax. While I kn ...

Serialize custom objects with an array of custom objects using Spring Boot and JSON

Let's take a look at this interesting class structure: @Id @GeneratedValue(strategy=GenerationType.AUTO) private long id; private int key; private String text; private Tag[] tags; private String title; private boolean valid; public Activity(int key, Strin ...

JSON is not conforming to the standard nesting level

After simplifying, the JSON implementation is as follows: Data(Entity)->"data"->another Entity I originally thought I could decrypt the Data object first, extract a type from it, and then use that type to decrypt the necessary type from the String "d ...

Spring MVC is preventing the completion of the request due to CORS restrictions

Currently facing a CORS problem while trying to send requests from React.js to my spring MVC application. I have attempted to enable it in the ApplicationContext.xml file with no success. Added the following lines to the applicationcontext.xml file, but e ...

Despite encountering Error 404 with AJAX XHR, the request is successfully reaching the Spring Controller

I am attempting to upload a file with a progress bar feature. var fileInput = document.getElementById('jquery-ajax-single') var form = new FormData(); form.append('uploadFile',fileInput.files[0]); $.ajax({ url: "fi ...

Discovering the Java Map's value in Typescript

My application's backend is built using Spring Boot and the frontend is Angular 7. I need to send a map as a response, like this: Map<String, Object> additionalResponse = new HashMap<>() { { put("key1"," ...

Experiencing a Cross-Origin Resource Sharing (CORS) error when attempting to establish a connection between a Spring Boot application and React, and

I've encountered an issue with my deployment setup involving a React application on NGINX running on port 9000 and a Spring Boot WAR file deployed on Tomcat server on port 8081. Despite enabling global CORS in Spring Boot, I'm still facing difficulties as ...

Spring Security OAuth - redirecting to the client application

Creating an API with Spring secured by Oauth2 was successful. The configuration file for Facebook is as follows: clientId: xxx clientSecret: xxxx accessTokenUri: https://graph.facebook.com/oauth/access_token userAuthorizationUri: https://www.facebook.com/ ...

There is an issue occurring with Minium involving glue and the browser

Can anyone explain why Minium (Selenium Webdriver Java + Cucumber) is generating this error trace? I've been trying to troubleshoot for hours, but nothing seems to resolve this issue. Project Structure https://i.stack.imgur.com/aqbGA.png Java: import ...