正确认识SpringMVC重定向视图RedirectView

时间:2024-04-12 19:37:24

RedirectView属性:

正确认识SpringMVC重定向视图RedirectView

private boolean contextRelative = false;

是否使用项目路径。默认不使用

private boolean http10Compatible = true;

是否兼容HTTP1.0,默认兼容
private boolean exposeModelAttributes = true;

是否暴露重定向参数,即重定向后地址是否带有查询参数,默认暴露(但重定向请求方式还为GET
private String encodingScheme;

编码格式
private HttpStatus statusCode;

响应状态
private boolean expandUriTemplateVariables = true;

是否将路径的变量转换成值:比如test/{id}转成test/001,默认转换

private boolean propagateQueryParams = false;

是否传播查询参数,默认不传播

 

RedirectView渲染过程:

正确认识SpringMVC重定向视图RedirectView