Render Html/js from server side in Spring boot .I want that when there is a backend REST Api call .I want to render everything in js but not using jsp .I want to know how to use viewResolver so that I can do it in js using xhr requests and html .
Thanking you in advance ,any help will be extremely helpful
I don't know if i understood your problem correctly but for spring there is a good extension Hateoas to build RESTful APIs. There you can define how to render your output.
https://spring.io/guides/gs/rest-hateoas/
Related
I´m working on an ASP.NET MVC project, that does the following:
Users collect data using an android app, this data is being sent as json. This app is under development by someone else, not me, but we´re in contact.
I created a JSONController with the following action:
[HttpPost]
public JsonResult PutJSON(JSONModel json){
// do something
}
My JSONModel only contains a public string LastName for testing purposes.
For now, I can only publish the project to IIS on localhost, which can be accessed from other devices in my home network. As far as I know, that should be okay for testing, right? The project is accessible and works when entering the ip of that machine in a browser on another device in network.
Is there anything else I need to do in my ASP.NET MVC project to make it accept AJAX calls from "outside"? Am I missing something?
I tried to test with a simple AJAX call from another device, but that´s just giving me internal server errors, because of cross domain call. Accepting those cross domain calls didn´t work though (do I need this when the project is finally being published?)
I´d be very thankful if someone could help, maybe by providing a link to a tutorial explaining how to configure ASP.NET project to accept AJAX calls from the internet.
Please take a look in the following question:
How to pass JSON POST data to Web API method as object
How to receive JSON data on WebAPI backend C#?
How to receive JSON as an MVC 5 action method parameter
How to receive JSON in asp.net web API?
Hope these will help you.
I need to know how data returned from the Spring MVC REST controller attaches to html page and what the Spring configuration do we have to do this.
The browser just prints this data out without view and that's all.
I have some Spring configurations to do it but unfortunatelly it doesn't work.
First, you have to create a spring web-mvc application with a correct configuration that will run without errors. There are plenty of tutorials on how to do it. After that, if you wish to get json data using your rest controllers, the most popular way to do it is by using javascript and the JQuery library. Using them you can make ajax calls to your api. There are plenty of tutorials on how to achive this again. Finnaly, your data will be on the client side and you can manage them (render them in your html-dom etc) using javascript and JQuery again.
IntelliJ can deploy HTML/JS code at localhost:63342 on the fly. I can see how the frontend behaves immediately.
Now I have a web application.
http://localhost:8080/frontend
http://localhost:8080/backend
The frontend will fetch data from its backend. Now I cannot start a real backend at localhost:63342. How can mock some ajax response at localhost:63342. Is there any magic plugin of IntelliJ can help?
My current solution is put all ajax call in an Angular service module and replace it with a mocked service module. I believe there must be some better solutions.
If you want to mock up some endpoints for you to test with I would suggest you use Mockjax. This will allow you to do exactly what you want and you won't have to run two separate apps to do so. I'm not familiar with IntelliJ, but Mockjax only has a dependency on jQuery and you should be able to easily set it up with any project that at least uses jQuery.
I need to create a Web Service in ASP classic(no choice unfortunately) but I need to do it using more modern standards like using JSON instead of SOAP. I'v been searching the web but I can't seem to find any way to do this. Is it even possible? and if it is can you please show me a tutorial or example.
Here are a few resources that may provide some of the information you need:
https://softwareengineering.stackexchange.com/questions/88556/how-to-make-classic-asp-interesting-if-you-are-stuck-with-it
Calling REST web services from a classic asp page
Can I build a REST application using ASP Classic?
ASP Classic example of REST / JSON call: https://gist.github.com/joseph-montanez/1948929
My c# WebService Class has these Compiler Tags:
[WebService(Namespace = "http://myWebService/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
Since it was requested that the WebService can also communicate with JSON clients we added this Compiler Tag:
[ScriptService]
Methods are tagged with
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
It all works fine with SOAP clients and with JSON clients but the
JSON Developers want to get Standard Status Codes in case the
WebService throws an Exception and I don't know how to
accomplish this.
I am developing my first HTML 5 application which has to read data from a web service.
Can anybody tell me how I can call a web method from HTML 5 using JavaScript ?
In this question you have an answer what should you put in order to call a web method in HTML.
How can I call this HelloWorld web method with plain JavaScript/Ajax, without using JSON or anything?
It is using ajax, but it should give you an example. Also take a look at the answer