java Play框架停留在同一页面上,然后更改语言
我正在使用java的play框架
我想问你们一个问题,是否有可能从Http请求中获取路由方法而不是url或路径,因为我需要更改一些路由参数值,以便能够以不同的语言url打开网页。例如:
POST /namai.html controllers.Application.postComment(String lng="ru")
POST /home.html controllers.Application.postComment(String lng)
http://localhost:9000/en/namai.html **I would get bad request call**
http://localhost:9000/ru/namai.html **Page would open but link would be not the same language.**
我不能仅仅替换语言前缀,因为我只能用英语打开url。你知道如何从http请求中获取路由方法吗?提前谢谢
# 1 楼答案
若有人遇到同样的问题,最简单的解决方法是使用java反射调用反向路由类并激活所需的方法