Solve the problem that https becomes http after using redirect in springmvc

Method 1: The configuration file modifies the redirectHttp10Compatible property of ViewResolver, which is to be compatible with the http1.0 protocol.

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
  <property name="prefix" value="/" />
  <property name="suffix" value=".jsp" />
  <property name="redirectHttp10Compatible" value="false" />
</bean>

Method 2: Instead of using return "redirect:/xxx" directly in the code, use 

modelAndView.setView(new RedirectView("your redirect URL",true,false));

This is the interface document of RedirectView

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324809188&siteId=291194637