SpringFramework_3008

Last modified by superadmin on 2018-01-12 20:19

Back to Item Set

<p/>
<!-- START TestItem -->
<p/>
<div class="TestItem">
<div class="TestItemQuestion">3008 Question:\

What are correct ways to configure HandlerInterceptors in a Spring web application?

</div>

Select 2 correct answer(s)!

<p/>
<ol class="MTestItemChoices" type='A'>
<li>

Adding the following class:
{code}
@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {
  @Override
  public void addInterceptors(InterceptorRegistry registry) {
    registry.addInterceptor(new LocaleInterceptor());
    registry.addInterceptor(new SecurityInterceptor()).addPathPatterns("/secure/*");
 }
}
{code}

</li>
<li>

Adding the following class:
{code}
@HandlerInterceptors
public class HandlerInterceptorsConfig extends WebMvcConfigurerAdapter {
  @Override
  public void register(InterceptorRegistry registry) {
    registry.addInterceptor(new LocaleInterceptor());
    registry.addInterceptor(new SecurityInterceptor()).addPathPatterns("/secure/*");
 }
}
{code}

</li>
<li>

In a context configuration file:
{code}
<mvc:interceptors>
    <mvc:interceptor class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
    <mvc:interceptor class="org.example.SecurityInterceptor" mapping="/secure/*"/>
</mvc:interceptors>
{code}

</li>
<li>

In a context configuration file:
{code}
<mvc:interceptors>
    <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
    <mvc:interceptor>
        <mapping path="/secure/*"/>
        <bean class="org.example.SecurityInterceptor" />
    </mvc:interceptor>
</mvc:interceptors>
{code}

</li>
</ol>
<p/>
<div class="TestItemSkill"><!--$skillid>Skill: $skilltitle</div>
<p/>
</div>
<!-- END MTestItem -->
<p/>
<p/>


{{/velocity}}

Tags:
Created by Alina Vasiljeva on 2013-01-13 11:23
    
This wiki is licensed under a Creative Commons 2.0 license
XWiki Enterprise 6.4 - Documentation