Spring mvc form processing without using spring tag

I recently studied a new framework with the goal of creating a web application. To this end, I wanted to try Spring MVC. Of the many evaluation parameters of the framework, I want to say that I do not want to bind to the libs tags associated with the framework in order to use the HTTP request parameter β†’ Java bean. The Spring MVC documentation repeatedly mentions that you can do viewing-related things only with JSTL and no Spring tags, however, I have not found a way to get the Request-to-Bean [ SimpleFormController ] translation function to work without Spring tags.

At the moment, the only way, apparently, is to retrieve the request parameters one by one and install on my bean. Is there any way to do this translation without using frame-dependent tags?

I appreciate your details!

+4
source share
3 answers

I am using Spring Web MVC without Velocity templates (templates without JSP). To answer your question, you need to understand how Spring performs data binding. Basically, all this is in the name that you give to your input elements. for instance

 <input name="properytOne" value="1" type="hidden"> <input name="properytTwo" value="2" type="hidden"> <input name="rich.property3" value="3" type="hidden"> 

will bind values ​​to an object like this

 class CommandOne { private String propertyOne; private String popertyTwo; private CommandTwo rich; // Getters and setters } class CommandTwo { private String propertyThree; // Getters and setters } 

You must also be sure to instantiate the command object, but this will be handled in your SimpleFormController.

+2
source
Tags

Spring is completely optional.

Read chapters 15, 16, and 17 of the Spring reference document . You can use annotations to retrieve query parameters using your controller (see section 15.3).

+1
source

In my understanding, what you are trying to achieve is to bind your form to the Bean class, which is very well implemented in JSF. JSF works with component architecture and is very easy to start with, and also has many components that can be used as components, such as perforated elements, panels, ice surfaces, open surfaces, etc. Reusing self-tuning components can help you with specific projects. Try to give a chance to JSF. Thanks, hope this was helpful.

0
source

Source: https://habr.com/ru/post/1341307/


All Articles