I am using Spring MVC in the backend system and HTML, AJAX, JSON with jQuery in the frontend system. I have two pages. The first one is called: http://localhost:8080/myproject/start
There I initialize data and make AJAX/JSON calls within jQuery's
$(document).ready(function() { ... });
But in this page I have a link on the next page: http://localhost:8080/myproject/nextpage/ID where ID is an unique number.
The problem is, this number do I need in the backend system to load m开发者_开发问答ore data. So I have in the backend system:
@RequestMapping(value="/nextpage/{ID}", method=RequestMethod.GET)
public String getCreateForm(Model model) {
return "nextpage/nameofthejsp";
}
So all I do is to call the JSP and there is also a
$(document).ready(function() { ... });
So, how can I access the ID number of the URL within jQuery? Or, I have this ID number first in the backend system, can I handle this number there instead of loading the frontend and then make a call to the backend?
Does anyone has an idea?
Best Regards.
Not sure i understand correctly; You want to access the ID in the next page?
Is this what you are trying to do?
@RequestMapping(value="/nextpage/{ID}", method=RequestMethod.GET)
public String getCreateForm(@PathVariable("ID") int id, Model model) {
/**
Do something
**/
model.addAttribute("ID", id);
return "nextpage/nameofthejsp";
}
and in your nextpage/nameofthejsp JSP, ID will be accessible: ${ID}
精彩评论