Close
« Tutorial

Spring MVC - Themes with Default Settings MCQ

0/13
0 ✓
0 ✗

1. Which ThemeResolver implementation does Spring MVC use by default?

2. Which component uses a ThemeResolver to handle theme logic?

3. What is the default theme name used by FixedThemeResolver?

4. With the default theme settings, where must the theme properties file be placed?

5. What does a theme properties file define?

6. Which JSP tag is used to read a value from the current theme?

<%@ taglib prefix="spring"
    uri="http://www.springframework.org/tags"%>
<body style="background-color:
    <!-- read 'background' here -->;">

7. What will be the rendered output of this JSP line?

# theme.properties
background=pink
width=400px
<!-- JSP -->
<div style="width:<spring:theme code='width'/>;">Hi</div>

8. A theme file contains the line below. What will the link tag render as?

# theme.properties
main-css=/themes/t1/main.css
<!-- JSP -->
<link rel="stylesheet"
  href="<spring:theme code='main-css'/>"/>

9. Which class level annotation turns on Spring MVC features in a Java config class?

@Configuration
// add annotation here
@ComponentScan
public class MyWebConfig
    implements WebMvcConfigurer {
}

10. Which method of ResourceHandlerRegistry is used to set the folder that holds static files such as CSS?

registry.addResourceHandler("/themes/**")
    // set the folder here
;

11. A request for /themes/t1/a.css is made. Where will Spring look for the file?

registry
    .addResourceHandler("/themes/**")
    .addResourceLocations("/css-files/");

12. Which method is used to map a URL to a view name without writing a controller?

@Override
public void addViewControllers(
        ViewControllerRegistry registry) {
    registry.addViewController("/")
        // set the view name here
    ;
}

13. What does this configuration do?

@Override
public void configureViewResolvers(
        ViewResolverRegistry registry) {
    registry.jsp();
}

14. Which setup makes a page read its background color and width from a theme? Look at the code below.

# theme.properties
bg=pink
w=400px
<!-- page.jsp -->
<body style="background-color:
    <spring:theme code='bg'/>;">
  <div style="width:
    <spring:theme code='w'/>;">
    Text
  </div>
</body>

15. What is the status of theme support in Spring Framework 6.0 and later?

Join