记一次ssm下@controller路径解析的奇葩bug

    xiaoxiao2023-10-29  172

    问题是这样的,项目是标准的SSM框架,配置没有问题,之前一切正常,然后有一天早上重启服务之后,出现了奇葩的问题:

    部分url能正常访问,部分不能正常访问

    明明之前一直还好好的,服务器上的项目运行了一年多,要是配置问题的话早该出现了。重启没用,各种clean,查看tomcat配置,删了再布署,都没有用。于是上网查解决方案,找了半天全是说配置问题的,最后在这里找到了一点灵感:

    https://bbs.csdn.net/topics/392206786

    去控制台老老实实看映射的url是什么。

    结果:

    2019-05-25 16:52:57 -6259 [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] INFO ==> Mapp ed "{[/ws/user/getImgs],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public com.xxx.Tip com.xxxxxxxxxxxx.getImgs(javax.servlet.http.HttpServletRequest)

    2019-05-25 16:52:57 -6259 [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] INFO  ==> Mapp ed "{[/ws/user/getImgs],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public com.xxx.Tip com.xxxxxxxx.getImgs(javax.servlet.http.HttpServletRequest)

    而我代码里是这样的:

    拼起来不应该是/ws/getImgs吗?中间这个user是怎么来的???

    想到昨天我把另一个controller中的路径改动了,原来是这样:

    改完之后是这样:

    理论上没有区别不是吗?况且,就算要有影响,也应该影响/user下的url才对,这俩根本没有什么关联吧?

    可是,我改为原来的样子之后,结果正常了。。。

    2019-05-25 17:23:39 -5338 [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] INFO ==> Mapp ed "{[/ws/getImgs],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public com.xxx.Tip com.xxxxxxx.getImgs(javax.servlet.http.HttpServletRequest)

    大佬们帮帮忙,有谁知道这是什么原因吗?

    最新回复(0)