I'm developing Spring MVC application. I have several locale languages and when I change them on JSP pages which require their own request params, I get an exception like:
Required int parameter 'remedyId' is not present
The link I used to change locale is:
<a href="?language=en">
When I click the link, it overrides request parameters in current URL with it's own.
http://localhost:8080/medapp/remedyInfo?language=ru
Instead of:
http://localhost:8080/medapp/remedyInfo?remedyId=1&language=ru
I suppose there is syntax to add multiple request parameters to current URL, but I don't know it. Thanks.
Related
When I enter the URI http://localhost:9000/dashboard or any other URI that uses the http POST method I always get errors, this is my handler
e.POST("/dashboard", controller.Dashboard)
When you type an URL into a browser, it will send a GET. To handle it you must use e.GET("/dashboard", controller.Dashboard) in your application.
If the page contains a form that submits a POST, you must handle both GET and POST. Both can be mapped to controller.Dashboard if desired, but it is normally easier to use different handlers.
I am developing a Laravel 5.6 project in localhost and I need to redirect it to an external website with a string parameter.
I found this on laravel 5.6 Documentation
Redirecting To External Domains
Sometimes you may need to redirect to a domain outside of your application. You may do so by calling the away method, which creates a RedirectResponse without any additional URL encoding, validation, or verification:
return redirect()->away('https://www.google.com');
I used the data from a form and created a variable including the data as requested inside the controller. Then added the parameter at the end line this.
return redirect()->away('https://sandbox.payhere.lk/pay/checkout')->with('$Payhere');
It redirects to required page and shows the error
"Error!!! Required String parameter 'rid' is not present "
I am watching this pluralsight demo video on Web Api, and he is using fiddler to pass in a parameter using Http Get with the syntax of controller/parameter
So he's using http://localhost:2405/api/values/5
5 Is the parameter he's passing in.
In my code, I have everything set up exactly the same way he does... with a routing template of {controller}/{id} and a controller method with a signature of
public string Get(string zipcode)
I can pass a parameter just fine with http://localhost:2405/api/values?zipcode=25252 but if I try passing in a paramter the way he does, like http://localhost:2405/api/values/25252 I get an error saying I do not have an action available to handle that request on the controller.
What is he doing right, that I'm doing wrong?
You need to change your routing template to {controller}/{zipcode} as the name of the parameter must match the name in the template.
I want to know how to get full request url
I need #test=1234 but using HttpServletRequest request.getRequestURI() or request.getRequestURL().toString()
return path only, like https://stackoverflow.com/myquestion
Help me
#test=123 is called an Anchor. And Anchors are not submitted to the server, they only reside in the Broswer
#see:
How to get the anchor name in HTTP GET?
Retrieving Anchor Link In URL for ASP.Net
Anchors or URL fragments are not sent by the client to the server when requesting for a resource. The anchor's or fragment's are utilized to identify a location within a resource and not a different resource on the server.
Fragment URL is not part of the URL. You can get the anchor using javascript & save them in cookies to retain them.
var anchor = window.location.hash;
I am trying to localize Lenya publication URLs.
I store URL translation in the Document metadata and rewrite urls with URLRewriter transformator.
e.g. I build
/lenya/default/authoring/en/home
from
/lenya/default/authoring/index.html
But I can't find a simple way to force Lenya to tranlate incoming request URI back to the original path: /lenya/default/authoring/index.html
Really I want to process the request via pipelines using the original URL, not translated.
Is it possible at all? I had tried to add a servlet filter and use dispatcher, but filter can't access documents metadata because Environment object isn't in the processing stack yet at this stage...
(At this moment I see only one way - to update CocoonServlet and Cocoon classes)
Thanks!
I was able to do this via a RequestListener.
In the public void onRequestStart(Environment environment) method I create RequestWrapper with a new real URL and put it into objectModel. Also I change Environment context with a real URL: env.setContext("", realUrl, env.getContext())
This works fine!