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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
26 views

Spring boot: multiple bean method which return same datatype across different Service classes

These two are Service classes, which makes http calls to other services to retreive the json response. Just wanted to know if this is a proper way to use ResourceConverter which helps to convert json ...
  • 101
0 votes
0 answers
41 views

Copy AWS S3 objects into DB

I have written a code which fetched the S3 objects from AWS s3 using S3 sdk and stores the same in our DB, the only problem is the task is repeated for three different services, the only thing is ...
  • 11
1 vote
2 answers
515 views

Using Factory Design Pattern in Rest Controller of Spring

I used factory design pattern to identify the service according to the enum that comes from the api uri as request param. Everything seems okay according to me but cannot be sure if I used it right. <...
3 votes
1 answer
81 views

A controller for a Game Service

I have a Spring MVC controller but I'm not sure that it is a good or bad design. As far as I know, api versioning is missing but apart from that I implemented Swagger for documentation and added ...
  • 31
0 votes
1 answer
1k views

Spring boot: better way to handle response and exceptions

I am working on a quite a big Spring Boot web service and I wanted a standardized and simplified way to handle responses and exceptions by following fluent API design. So this is what I did and it ...
0 votes
1 answer
119 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
1 answer
140 views

In Spring framework, should the controller let the client know that something went wrong by returning a response entity with the proper error code?

Category Service: ...
13 votes
2 answers
1k 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: ...
  • 395
2 votes
2 answers
6k 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. ...
  • 799
14 votes
4 answers
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: ...
  • 311
4 votes
1 answer
24k 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
0 answers
777 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
0 answers
91 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,526
1 vote
0 answers
428 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 ...
  • 111
3 votes
1 answer
3k 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 ...
  • 131
0 votes
1 answer
48 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: ...
  • 113
1 vote
2 answers
111 views

Reporting sums of shopping carts

I have an object (ShoppingCart) that has a list of CartItems, which contains the related ...
  • 111
2 votes
1 answer
6k 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
1 answer
70 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 ...
  • 183
1 vote
0 answers
215 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
0 answers
39 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-...
  • 111
0 votes
1 answer
158 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
1 answer
115 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
0 answers
36 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 ...
  • 163
0 votes
1 answer
83 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 ...
  • 191
1 vote
1 answer
900 views

Spring MVC login controller

I am making a small project in Spring MVC. My login controller looks like this: ...
3 votes
1 answer
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
2 answers
9k views

Transaction in spring boot

I am using spring boot in my application. ...
  • 121
1 vote
2 answers
288 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 ...
  • 217
2 votes
1 answer
2k 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
0 answers
74 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 ...
  • 133
2 votes
1 answer
4k 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
3 answers
16k 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 ...
  • 141
1 vote
1 answer
346 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: ...
6 votes
1 answer
21k 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. ...
  • 61
1 vote
0 answers
617 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 ...
  • 191
1 vote
0 answers
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. ...
  • 11
0 votes
1 answer
488 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
1 answer
197 views

Spring MVC controller

My code has a nasty smell that looks like this: ...
  • 1,326
3 votes
2 answers
195 views

Throw exception in Spring when loading a file

I have this following piece of code: ...
3 votes
1 answer
149 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
1 answer
9k 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 ...
  • 343
6 votes
0 answers
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
2 answers
39k 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: ...
  • 727