Hello to everybody,
I am studing the Spring MVC showwcase dowloadable from the STS dashboard.
Now I am studing how Spring MVC mapping the resources and I have some problem to understand the following thing:
So, I have the following link that generate an HTTP Request towards the "/mapping/produces" folder:
As you can see this link have class named "writeJsonLink" and for this class there is defined the following JQuery function triggered on the click of the link:
Ok, I have commented the code to try to understand its behavior (I am a beginner of Javascript and JQuery) and seems me that the behavior of this script is the following one: When I click the link, start the function that before send the ajax call to the web application check if the url of the clicked link is an address that end with .json extension.
In this case this case my URL don't end with .json (because my url is towards the FOLDER: /mapping/produces and not towards a .json file), so the function don't add the header "Accept", "application/json" to the HTTP Request body field.
Ok, now my problem is to understand what do this piece of code:
In succes case call a function having a parameter named json that simply call a method named showSuccessResponse passing to it the json obkect converted to
String and the link.
Now, I know what showSuccessResponse do (I use it to create a span tag that show a message in my page next to the clicked link).
the problem is: who is the json parameter that I pass to the function in the success case. I am converting to String this parameter but: when and where I have created id?
If I execute my example when I click on the link appear me (next to the link) the following message:
{"foo":"bar","fruit":"apple"}
Seems ad it was created an JSON object having the following key\value contents:
foo: bar
fruit: apple
But where is it created ?!?! boooo
When I click on the link and the method is executed I have the following message in my stacktrace:
Can you help me to undestand what happen?
Thanks
Andrea