Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
147 views
in Programming by
retagged by
I am working on a spring boot application. How do I add form to my view?

1 Answer

0 like 0 dislike
by The go-to Tester (181 points)
Just follow instruction as below.

 

E.g. This is your form from jsp page.

 

<form method="post" action="/">
    <div>
        First name:
        <input type="text" name="firstName" th:field="*{firstName}"/>
    </div>
    <div>
        Last name:
        <input type="text" name="lastName" th:field="*{lastName}"/>
    </div>
    <div>
        SS Number:
        <input type="text" name="SSNumber" th:field="*{SSNumber}"/>
    </div>
    <div>
        <input type="submit"/>
    </div>
</form>

 

Your controller:

@RequestMapping(value = "/", method = RequestMethod.POST)
    public String eligibilityPost(
            @ModelAttribute("form") @Valid EligibilityModelsImpl form,
            BindingResult result, Model model) {
        eligibilityService.addEligibleUser(form);
        model.addAttribute("eligibilityModels", eligibilityService.getEligibilityList());
        return "eligibility";
    }

 

Let us know if you need more details.


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...