Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8363437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:10:30+00:00 2026-06-09T12:10:30+00:00

I want to do a mcq with Spring mvc. I’ve got a class Mcq

  • 0

I want to do a mcq with Spring mvc. I’ve got a class Mcq with a OneToMany relationship with the class Question, which has a OneToMany relationship with the class Answer. Thus Mcq have as property an Arraylist ListOfQuestions, and Question an Arraylist ListOfAnswers.

My controller is

    @RequestMapping(value="displayMcq", method = RequestMethod.GET)
public String showMcq(Model model) {
    Mcq mcq = mcqService.findById(new Long(1));
    model.addAttribute("mcq", mcq);
return "displayMcq";
}   

@RequestMapping(method = RequestMethod.POST)
public String displayQcmRepondu(@ModelAttribute("mcq2") Mcq mcq, BindingResult binding, SessionStatus status) {      
     if (binding.hasErrors()) {
         return "displayMcq";

 } else {
     status.setComplete();
     return "redirect:/mcqSuccess/";
    }
}

and my view displayMcq.jsp is

<form:form modelAttribute="mcq" method="POST">
        <ol>
            <c:forEach items="${mcq.listOfQuestions}" var="question">
                <li>
                    <c:out value="${question.label}" /> 
                    <br />
                    <ul>
                        <c:forEach var="answer" items="${question.listOfAnswers}">
                            <form:checkbox path="listOfQuestions" value="answer.id" label="${answer.label}" />
                            <br />
                        </c:forEach>
                    </ul>
                </li>
            </c:forEach>
        </ol>
        <input type="submit" value="Validate" />
    </form:form>

My mcq is well displayed but the processing of the form fails. I stay on the displayMcq appearance with the error “Etat HTTP 405 – Request method ‘POST’ not supported”.

So, could you explain me the problem, help me to proccess my mcq correctly and return the checked answers?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:10:32+00:00Added an answer on June 9, 2026 at 12:10 pm

    Note that your controller methods are mapped to different URLs (due to absence of value attribute on your POST method).

    Since you don’t have action attribute in <form:form>, it sends a POST request to the current page’s URL on submit, but you don’t have controller methods to handle POST request to that URL.

    So, you need to map your POST method to the same URL as your GET method:

    @RequestMapping(value="displayMcq", method = RequestMethod.POST)
    public String displayQcmRepondu(...) { ... }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

want to have a Hyperlink-Button in a gridView in which I can display a
Want to draw an UIImageView which has an CGImage, and the UIImageView has alpha
Want to verify that my understanding of how this works. Have a C++ Class
I'm developing a script for technical quiz which is going to have MCQ types
I am doing an application on a Multiple Choice Question (MCQ) where I have
Want to run javascript function from parent window in child window Example I have
want to create a temporary table that has an auto_increment field plus a field
Want to have vertical scroll bar if content is more than expected in popwindow...
Want to work with 4-5 devs over internet on PHP projects. Question : Is
want declarative transactional management example in spring aop........ Actually Here <aop:config> <aop:advisor advice-ref=addAdvice pointcut=execution(*

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.