Clean up property values registration in SimpleWebApplicationContext

Closes gh-22787
master
Juergen Hoeller 6 years ago
parent b07d46da99
commit 722cd179cf
  1. 9
      spring-webmvc/src/test/java/org/springframework/web/servlet/SimpleWebApplicationContext.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -47,10 +47,6 @@ public class SimpleWebApplicationContext extends StaticWebApplicationContext {
@Override @Override
public void refresh() throws BeansException { public void refresh() throws BeansException {
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("commandClass", "org.springframework.tests.sample.beans.TestBean");
pvs.add("formView", "form");
registerSingleton("/locale.do", LocaleChecker.class); registerSingleton("/locale.do", LocaleChecker.class);
addMessage("test", Locale.ENGLISH, "test message"); addMessage("test", Locale.ENGLISH, "test message");
@ -63,7 +59,7 @@ public class SimpleWebApplicationContext extends StaticWebApplicationContext {
registerSingleton("handlerMapping", BeanNameUrlHandlerMapping.class); registerSingleton("handlerMapping", BeanNameUrlHandlerMapping.class);
registerSingleton("viewResolver", InternalResourceViewResolver.class); registerSingleton("viewResolver", InternalResourceViewResolver.class);
pvs = new MutablePropertyValues(); MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("location", "org/springframework/web/context/WEB-INF/sessionContext.xml"); pvs.add("location", "org/springframework/web/context/WEB-INF/sessionContext.xml");
registerSingleton("viewResolver2", XmlViewResolver.class, pvs); registerSingleton("viewResolver2", XmlViewResolver.class, pvs);
@ -76,6 +72,7 @@ public class SimpleWebApplicationContext extends StaticWebApplicationContext {
@Override @Override
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { throws ServletException, IOException {
if (!(RequestContextUtils.findWebApplicationContext(request) instanceof SimpleWebApplicationContext)) { if (!(RequestContextUtils.findWebApplicationContext(request) instanceof SimpleWebApplicationContext)) {
throw new ServletException("Incorrect WebApplicationContext"); throw new ServletException("Incorrect WebApplicationContext");
} }

Loading…
Cancel
Save