spring-guides / getting-started-guides

Getting Started Guide template :: The template for new guides and also the place to request them.
https://github.com/spring-guides/getting-started-guides/wiki
Apache License 2.0
521 stars 204 forks source link

The 'handling-form-submission' guide needs a non-thymeleaf jsp version of the guide #20

Open djangofan opened 8 years ago

djangofan commented 8 years ago

The 'handling-form-submission' guide needs a non-thymeleaf, jsp version of the guide

https://spring.io/guides/gs/handling-form-submission/

The "form submit" guide should have a GOAL of BEING EASY but, as a beginner, I had great difficulty reconciling other jsp Spring examples of form submission (found around the internet) with this guide. Basically, if I say it another way, your site does not currently a "form submit" example in your guidebook that shows how to do a form submit the standard way, using jsp (non-thymeleaf/html template).

Also, I think I would find the guide better if it did not use spring-boot , and instead just did it the traditional way. I think the guide would be easiest using a .xml spring config, but an annotated config would be acceptable. Additionally, if there is more than 1 way to submit a form, there should be 1 controller for each example.

gregturn commented 8 years ago

@rstoyanchev Would you care to weigh in here?

rstoyanchev commented 8 years ago

XML vs Java config and JSP vs Thymeleaf doesn't make the sample easier or harder, just more or less aligned with your application stack. That said the general idea (and the server side code) should be the same. I'm curious what difficulty did you run into with replicating the same with JSP?

As for the use of Boot that's a decision across all GS guides. It does enable the ability to be up and running in 15 min. It isn't possible otherwise.

@gregturn taking a look what I find lacking is at least one binding/validation failure. Adding a JSR-303 anotation, @Valid to the model attribute, a BindingResult argument after it, and and error tag in the template shouldn't be that much harder and is a fundamental thing to show even in the most basic example. Also on success a redirect to the result page (vs rendering in the same POST).

djangofan commented 8 years ago

Thanks. I'll run through the example today or tomorrow, once again, and then reply to this thread once more with exact details on the parts of this form-submit guide that I found troublesome.

In the meantime, I agree that spring-boot + thymeleaf is faster to get up and running but it seems to me that Thymeleaf hides a little bit of the implementation detail from people, when they are trying to learn how the pure version of Spring libraries work? For example: the example shown is not testable with MockMvc unless you move the .html/.jsp file locations to under WEB-INF?

djangofan commented 8 years ago

Ok, finally had time to follow up on this:

Things I noticed after starting with 'gs-handling-form-submission' demo project, and using that as a template to build my own:

https://github.com/djangofan/spring-boot-mortgage-calculator

  1. Including the .war task in the build.gradle would have made sense, for optional deployment to another container.
  2. Leave a link in the documentation that explains why using spring-boot with thymeleaf was chosen. It is very confusing for a beginner, not knowing why.
  3. Had trouble posting a Date object. Added code in 'config' package to handle it. I found that posting a Date was a basic necessary feature on a form and I had to add a number of lines of code and bang my head against the wall for an hour or two until I figured it out.

Thats all. I guess the doc doesn't need as much update as I originally thought but I think I identified a couple things that would improve it?