title: How to set defaultHtmlEscape to true without XML in Spring MVC?
body: <p>I want to avoid using XML configurations and therefore I made my <code>AppConfig</code> class where I have plenty of beans for different purposes.</p>
  
  <p>I can't find how to prevent a XSS by setting <code>defaultHtmlEscape</code> inside my <code>AppConfig</code>. Everything I found was a config per form or globally in XML config.</p>
  
  <p>My <code>AppConfig</code> now:</p>
  
  <pre><code>@EnableJpaRepositories(basePackages="org.maguss.repositories")
  @EnableTransactionManagement
  @EnableWebMvc
  @Configuration
  @ComponentScan({ "org.maguss.*" })
  @Import({ SecurityConfig.class })
  public class AppConfig {
  
      @Bean(name = "dataSource")
      public DriverManagerDataSource dataSource() {
          DriverManagerDataSource driverManagerDataSource = new DriverManagerDataSource();
          driverManagerDataSource.setDriverClassName("com.mysql.jdbc.Driver");
          driverManagerDataSource.setUrl("jdbc:mysql://127.0.0.1:3306/test");
          driverManagerDataSource.setUsername("root");
          driverManagerDataSource.setPassword("");
          return driverManagerDataSource;
      }
  
  
      @Bean
      public InternalResourceViewResolver viewResolver() {
          InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
          viewResolver.setViewClass(JstlView.class);
          viewResolver.setPrefix("/WEB-INF/pages/");
          viewResolver.setSuffix(".jsp");
          return viewResolver;
      }
  
      //////////////////////////
       @Bean
         public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
            LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
            em.setDataSource(dataSource());
            em.setPackagesToScan(new String[] { "org.maguss.model" });
  
            JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
            em.setJpaVendorAdapter(vendorAdapter);
            em.setJpaProperties(additionalProperties());
  
            return em;
         }
  
  
         @Bean
         public PlatformTransactionManager transactionManager(EntityManagerFactory emf){
            JpaTransactionManager transactionManager = new JpaTransactionManager();
            transactionManager.setEntityManagerFactory(emf);
  
            return transactionManager;
         }
  
         @Bean
         public PersistenceExceptionTranslationPostProcessor exceptionTranslation(){
            return new PersistenceExceptionTranslationPostProcessor();
         }
  
         Properties additionalProperties() {
            Properties properties = new Properties();
            properties.setProperty("hibernate.hbm2ddl.auto", "update");
          //  properties.setProperty("hibernate.hbm2ddl.auto", "create");
            properties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
            return properties;
         }
      //////////////////////////
  
  }
  </code></pre>