开发者

how can I refer to another mapped controller in spring mvc?

开发者 https://www.devze.com 2023-04-10 17:50 出处:网络
I have two files with @controller annotation the first contains @RequestMapping(\"students\") annotation and mapped methods like @RequestMapping(\"Add Student\",method=RequestMethod.post)

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 ?


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:

<spring:url value="/teachers/Add Teacher/"/>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号