如何在 spring mvc 中引用另一个映射控制器?
我有两个带有 @controller 注释的文件,
第一个包含 @RequestMapping("students") 注释和映射方法,如 @RequestMapping("Add Student", method=RequestMethod.post),
另一个包含 @RequestMapping("teachers") 注释和映射@RequestMapping("Add Teacher", method=RequestMethod.post) 等方法
映射方法“Add Teacher”返回“addTeacher”,这是一个 .jsp 文件。
在 addTeacher.jsp 中,我有以下链接:添加教师 但它不起作用,因为它转到 localhost:8080/SchoolProject/students/Add Teacher/ 我想转到 localhost:8080/SchoolProject/teachers/Add Teacher/
如何重写该 .jsp 文件中的链接以转到教师方法?
I have two files with @controller annotation
the first contains @RequestMapping("students") annotation and mapped methods like @RequestMapping("Add Student", method=RequestMethod.post)
the other one @RequestMapping("teachers") annotation and mapped methods like @RequestMapping("Add Teacher", method=RequestMethod.post)
The mapped method "Add Teacher" returns "addTeacher" which is a .jsp file.
In addTeacher.jsp I have this link: Add Teacher
but it doesn't work because it goes to localhost:8080/SchoolProject/students/Add Teacher/
I want to go to localhost:8080/SchoolProject/teachers/Add Teacher/
How can i rewrite the link from that .jsp file to go to teachers method ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不能 100% 确定我完全理解你的问题。但是您可能可以使用 spring 标签库(具体来说: http://static.springsource.org/spring/docs/3.1.0.M2/spring-framework-reference/html/spring.tld.html#spring.tld.url)
像这样的东西应该有效:
I'm not 100% sure I am fully understanding your issue. But you can probably use the spring tag library (specifically: http://static.springsource.org/spring/docs/3.1.0.M2/spring-framework-reference/html/spring.tld.html#spring.tld.url)
Something like this should work: