如果url在我的参数控制器中有%2F,则返回404. Spring MVC 4.2.1

时间:2018-03-21 21:27:31

标签: java spring

我有斜杠的param,它编码为UTF-8,但服务器返回404错误。如何从我的上一个参数中排除斜杠或%2F。在我的项目中,我只使用注释。

我无法更改任何结构和网址,因为我的网站处于最佳状态,Google告诉我解决这个问题,因为索引网址会返回404。

网址示例,斜杠:

/ RU /天气/ 7 / Neustad%2FNord_DE

/ DE / weather7 /赖欣巴哈%2FVogtland_DE

拥有控制器

    @RequestMapping({
            "/",
            "/forecast/{locationRequest:.+}",
            "/forecast/today/{locationRequest:.+}",
            "/weather/today/{locationRequest:.+}",
            "/weather/map/{locationRequest:.+}",
            "/forecast/map/{locationRequest:.+}",
            "/forecast/tomorrow/{locationRequest:.+}",
            "/weather/tomorrow/{locationRequest:.+}",
            "/weather/history1/{locationRequest:.+}",
            "/weather/history3/{locationRequest:.+}",
            "/forecast/3/{locationRequest:.+}",
            "/weather/3/{locationRequest:.+}",
            "/forecast/5/{locationRequest:.+}",
            "/weather/5/{locationRequest:.+}",
            "/forecast/7/{locationRequest:.+}",
            "/weather/7/{locationRequest:.+}",
            "/forecast/10/{locationRequest:.+}",
            "/weather/10/{locationRequest:.+}",
            "/forecast/14/{locationRequest:.+}",
            "/weather/14/{locationRequest:./+}",
            "/forecast/hour-by-hour1/{locationRequest:.+}",
            "/weather/hour-by-hour1/{locationRequest:.+}",
            "/forecast/hour-by-hour3/{locationRequest:.+}",
            "/forecast/detailed3/{locationRequest:.+}",
            "/forecast/detailed1/{locationRequest:.+}",
            "/weather/detailed1/{locationRequest:.+}",
            "/weather/detailed3/{locationRequest:.+}",
            "/weather/hour-by-hour3/{locationRequest:.+}",
            "/weather/widgets/{locationRequest:.+}",
            "/weather/climate/{locationRequest:.+}"
    })
    public ModelAndView index(@PathVariable(value = "locationRequest") String locationRequest) {}

另外在我的application.properties中有

org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH =真

在主要班级我也做了

    System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");

0 个答案:

没有答案