Как я могу добавить амперсанд для значения в значении файла конфигурации приложения ASP.net/C#

Чтобы добавить перехватчик в приложение загрузки весны, выполните следующие

  1. Создайте класс перехватчика
    public class MyCustomInterceptor implements HandlerInterceptor{
    
        //unimplemented methods comes here. Define the following method so that it     
        //will handle the request before it is passed to the controller.
    
        @Override
        public boolean preHandle(HttpServletRequest request,HttpServletResponse  response){
        //your custom logic here.
            return true;
        }
    }
    
  2. Определите класс конфигурации
    @Configuration
    public class MyConfig extends WebMvcConfigurerAdapter{
        @Override
        public void addInterceptors(InterceptorRegistry registry){
            registry.addInterceptor(new MyCustomInterceptor()).addPathPatterns("/**");
        }
    }
    
  3. Вот оно. Теперь все ваши запросы пройдут через логику, определенную с помощью метода preHandle () MyCustomInterceptor.
198
задан Rob Segal 17 December 2008 в 21:45
поделиться

3 ответа

Используйте" &" вместо "&";.

402
ответ дан Eric Rosenberger 4 November 2019 в 14:45
поделиться

Вы попробовали это?

<appSettings>  
  <add key="myurl" value="http://www.myurl.com?&amp;cid=&amp;sid="/>
<appSettings>
24
ответ дан BenAlabaster 4 November 2019 в 14:45
поделиться

Я думаю, что необходимо смочь использовать символ ESC HTML (&). Они могут быть найдены в http://www.theukwebdesigncompany.com/articles/entity-escape-characters.php

4
ответ дан ICR 4 November 2019 в 14:45
поделиться
Другие вопросы по тегам:

Похожие вопросы: