Home > MCQs > IT & Programming > Spring MVC MCQs

Spring MVC MCQ

Spring MVC Quick Quiz

Question 1 of 10
  • For the following Java configuration, Explain why the Cross Site Request Forgery protection is not correctly configured?

    @EnableWebSecurity 

    public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override 

    protected void configure(HttpSecurity http) throws Exception { 

        http .csrf().disable(); 

    } }

    Answer & Explanation

    Correct Answer:

    Need to include the @Configuration annotation in the class definition 

    Note: This Question is unanswered, help us to find answer for this one

  • What is the difference between the @Repository and the @Controller annotations in Spring?

    Answer & Explanation

    Correct Answer:

    "@Repository" is used as a stereotype for the persistence layer, while "@Controller" is used as a stereotype for the presentation layer. 

    Note: This Question is unanswered, help us to find answer for this one

  • Which of the following statements is true about the @ModelAttribute annotation?

    Answer & Explanation

    Correct Answer: It can be used to expose reference data to a web view.

    Note: This Question is unanswered, help us to find answer for this one

  • Which of the following statements is true about the @RequestParam annotation?

    Answer & Explanation

    Correct Answer: It indicates that a method parameter should be bound to a web request parameter.

    Note: This Question is unanswered, help us to find answer for this one

  • Fill in the blank:

    The _______ enables the use of the bean element’s attributes, instead of nested <property/> elements, to describe property values and/or collaborating beans.

    Answer & Explanation

    Correct Answer:

    p-namespace


    Note: This Question is unanswered, help us to find answer for this one

  • Fill in the blank:

    In Spring's XML-based configuration, the _______ attribute of the <property/> element specifies a property or constructor argument as a string representation.

    Answer & Explanation

    Correct Answer:

    name

    Note: This Question is unanswered, help us to find answer for this one

  • Which statement is correct for @Controller annotation?

    Answer & Explanation

    Correct Answer: The @Controller annotation indicates that a particular class serves the role of a controller. It does not require you to extend any controller base class or reference the Servlet API.

    Note: This Question is unanswered, help us to find answer for this one

  • What does the following code do?

    @RequestMapping("/{id}/**")

    public void foo(@PathVariable("id") int id, HttpServletRequest request) {

        String restOfTheUrl = (String) request.getAttribute(

            HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);

        ...

    }

    Answer & Explanation

    Correct Answer:

    It retrieves the partial path value (after "**") before the @RequestMapping and @PathVariable values have been parsed.


    Note: This Question is unanswered, help us to find answer for this one

  • Which of the following is true about the use of <context:annotation-config /> in a servlet?

    Answer & Explanation

    Correct Answer:

    <context:annotation-config> activates many different annotations in beans, whether they are defined in XML or through component scanning.


    Note: This Question is unanswered, help us to find answer for this one

  • Fill in the blank: _______ is a class-level annotation indicating that an object is a source of bean definitions.

    Answer & Explanation

    Correct Answer: @Configuration

    Note: This Question is unanswered, help us to find answer for this one

  • Spring MVC Quick Quiz

    battery

    Poor Results!

    You need a lot of improvement.

    Just don't give up!

    Correct Answers: 0/10

    Start Practicing with our MCQs given below.