Questions tagged [spring-mvc]
Based on the Model-View-Controller (MVC) pattern, Spring MVC helps you build web-based applications that are flexible and decoupled from the underlying view technologies.
43
questions
0
votes
1answer
78 views
Microservice in Springboot
I wrote two microservices in Springboot and tried to follow the best practices. I would appreciate any suggestions about any improvement that I can make on the whole codebase. What are the parts of ...
1
vote
1answer
90 views
11
votes
2answers
335 views
Stack Overflow clone
I have to write a simple web application using the Java Spring framework as my course project. So I decided to write a simple Stack Overflow clone. My application has the following features:
...
1
vote
2answers
60 views
Return a 404 when a resource is not found in Spring Boot
I wrote this code in order to return a http status of not found to my users in case the resource is not present in the DB.
...
1
vote
0answers
29 views
Return new thymeleaf page from controller [closed]
0
I have a web app built using Spring boot and thymeleaf. I have used only the index page so far which has different models in it and it work just fine.
Now I want to add a new page. By new page I ...
13
votes
4answers
3k views
Unit testing Video Service class
I wrote my first unit testing code on a service class using Mockito. The code looks like this:
...
3
votes
1answer
4k views
Simple Banking application in Spring boot, JPA, REST where balance can be transferred among predefined accounts and transaction history retrievable
I want to create a very simple banking application where (i) predefined accounts with a positive balance can send money (ii) requesting balance and a list of transactions can be found.
I have ...
1
vote
0answers
374 views
Spring Boot - JPA query execution Time
Any one suggest me right way to write mapping more then one table using spring-boot (jpa), i was done it, but its required more time to extract result,
Following are the Mapping of Pojo:
First:-
<...
2
votes
0answers
81 views
Given a resource ID, instantiate, retrieve and localize a Linked Resource for a REST API call
During a question on Stack Overflow, another user had some comments about the way this code works. He had a few choice words for it, including "magic", "ugly contraption", "you're doing things you ...
1
vote
0answers
306 views
Spring (boot) MVC Abstract Controller
I'm writing an application that will end up with a set of standard CRUD operations for a bunch of object types, and I thought it would help simplify things if all the separate controllers had some ...
3
votes
1answer
2k views
Effective & Secure Method to populate Access Token for authorization header in Rest Template
I am trying to consume a REST endpoint by using the RestTemplate Library provided by the spring framework.
The endpoint also demands a Bearer Access Token as its authorization header, which is only ...
0
votes
1answer
35 views
Spring Boot methods to add and remove relationships
I have a Spring Boot application and I wrote a piece of code to manage relationships between two entities.
The code consists mostly in these two methods:
...
1
vote
2answers
80 views
Reporting sums of shopping carts
I have an object (ShoppingCart) that has a list of CartItems, which contains the related ...
2
votes
1answer
5k views
CSV file download in Spring
I recently worked on a module, in which I implemented the functionality of downloading the CSV files.
...
0
votes
1answer
61 views
Refactor REST service with overcomplicated logic
Need to perform such actions:
receive JSON from REST
extract nexted JSON document
calculate hash of the nested document
add some fields to extracted document and save it in database
return response ...
1
vote
0answers
149 views
Business logic validation as custom Bean Validation annotations?
This is not my solution but that of an existing application I am enhancing.
Basically what they are doing is annotating a Form.java with a custom validator that ...
1
vote
0answers
35 views
Populating a CMS's database with some initial data
I have a simple content management system Spring-MVC web app made with spring boot.
I have the following class called data loader that initially creates some objects and stores them in an H2 in-...
0
votes
1answer
147 views
Refactoring a class / map of query parameters that are passed between layers
There is an interface:
interface JournalCreator {
@Async
Journal create(Parameters params);
}
And many different implementations:
...
2
votes
1answer
108 views
Maintaining session timeout globally in java spring configuration
Below is my code to maintain a session timeout globally in Java spring configuration and to load the session timeout value from a properties file. Do you have any suggestions to improve my code?
<...
2
votes
0answers
35 views
Security exceptions
I'm trying to configure security exceptions to all JavaScript/CSS of my pages.
I need to login to access the JSP files, except the login page, but all pages needs ...
0
votes
1answer
77 views
Spring: Creating a Mutable Common Command Object or Controller Interceptor
I'm integrating with a 3rd party vendor that has Users and Organizations in it. My tool is a user administration tool that ...
0
votes
1answer
48 views
Handling a response in a @Controller
I have a simple spring controller which takes a @ModelAtrribute object and registers an employee. If it is a success, I forward it to a success, else an error page, ...
1
vote
1answer
882 views
Spring MVC login controller
I am making a small project in Spring MVC. My login controller looks like this:
...
3
votes
1answer
4k views
Spring Boot RESTful service as a backend and reactjs as frontend app
let me please know what could be improved here.
I've developed backend + frontend solution for the following task:
Back-end:
Create a simple Spring Web MVC application and manage dependencies
...
2
votes
2answers
8k views
1
vote
2answers
275 views
Spring Mvc RESTful app with MySQL
I recently write a Spring MVC RESTful app and this is the REST controller that I have worked on. I haven't work with Spring RESTful for a while and hence, provided, the code for suggestions of how to ...
1
vote
1answer
1k views
Spring MVC @ControllerAdvice exception handling
This is about handling sql - foreign key constraint failure exceptions (SQL Error: 1452, SQLState: 23000) globally using ...
2
votes
0answers
63 views
Generate a patch description from multiple SVN commits
I have a Spring app that is used to create patches for another application.
My client retrieves a list of branches from a SVN repo through the initial AJAX call, then if one branch is chosen, another ...
2
votes
1answer
3k views
Service Layer in Spring Data
I'm building a small application in Spring and Spring Data JPA.
I need serval layer. I don't know if I'm doing well.
Here is an example:
POJO
...
4
votes
3answers
13k views
Inserting 100000 records to MySQL takes too much time
I'm using spring boot, hibernate any MySQL for reading 100000 records from csv file and write the same to the database. I'm doing the batch insert where the data is committed at intervals equal to ...
1
vote
1answer
338 views
Spring MVC, Mongodb and java
I am avery beginner at SPring MVC, Mongodb and java. I am trying to make a sample application so that the user can serach, create, update and delete a customer:
My CustomerDAO class:
...
1
vote
0answers
806 views
Uploading an image for a product in an online store
I am creating an online store using Spring MVC. The point is that when you create a new product you need to upload a picture for it. I am using the Cloudinary service, so when you upload, the image ...
6
votes
1answer
17k views
Spring MVC dynamically adding form elements
I made a simple form with an option of adding one text field dynamically on mouse click. And I will be grateful for suggestions on how I may improve the code.
...
1
vote
0answers
37 views
Formatting data in a UIViewController in a weight-training app
I'm writing a weight training app that calculates a one rep maximum and it has several options including recording your lifts in pounds or kilograms. I'm trying my best to follow the MVC pattern but I'...
1
vote
0answers
550 views
Spring MVC web app for simple ciphers
I'm working on a simple Spring MVC web app that allows users to encrypt and decrypt messages with classical ciphers such as the shift or Caesar cipher. It also allows users to auto-decrypt a message ...
1
vote
0answers
3k views
Spring MVC validation Multipart file in form
I need make validation of Multipart file in form class. I wrote custom annotation for form class which validate Multipart file. This code works great, but I don`t know if this is a good approach.
...
0
votes
1answer
448 views
Does this unit test cover all edge cases? [closed]
I want to test a simple controller and I want to know if this unit test covers all cases:
Controller:
...
1
vote
1answer
184 views
3
votes
2answers
109 views
3
votes
1answer
147 views
Spring controller code to group information by date
I'm using the Spring Framework in my web application and I'm curious as to whether my controller implementations are good or not.
I've used many Hashmaps to make a object that serves my purpose for ...
0
votes
1answer
8k views
Detect that a class is marked by a custom annotation in Spring
I would like to enable application behaviour based on the presence of a custom annotation that marks the configuration class (normally named something like ...
5
votes
0answers
2k views
Implement two level caching using spring's cache abstraction Cache and CacheManager
Details about spring's caching framework are here. When I was reading this link, I thought the composite cache mentioned there was one that used levels of caching based on the order given to the ...
10
votes
2answers
33k views
Preventing XSS attacks in a Spring MVC application controller
One of the URL in my application is vulnerable to XSS attack, so I am handling it in the below way.
I created a util class:
...