Java – wicket is changing the requesturl
I have a wicket application that can be deployed in different environments One environment is the server behind the HTTPS proxy (let's call it s) (let's call it p), so the pages on the application are accessed as
https://P:443/path/mountedPackage/Page?params=values
Everything is normal in wicket 1.4, but with the migration to wicket 1.5, the request URL is changed to
http://P:443/path/mountedPackage/Page?params=values
(HTTPS replaced by HTTP) leads to "400 error request" error I don't know why this happens, but it destroys my external links to the application
Note: I encountered the same problem before submitting the form and calling the method setresponsepage (page. Class). I solved it by setting different requesttargets and manually adding "HTTPS" instead of "HTTP" when corresponding:
In wicket 1.4
component.getRequestCycle().setRequestTarget (new RedirectRequestTarget("newURLWithPropperHttps"));
And in wicket 1.5
component.getRequestCycle().scheduleRequestHandlerAfterCurrent(new RedirectRequestHandler("newURLWithPropperHttps"));
But now I don't call any setresponsepage () or anything like that, which happens when it follows a normal link from the outside
Does it help? You can use the same solution as shown in the figure, but I don't know where to implement it (I've tried the method get() of irequestcycleprovider, but this leads to an anohter error)
Solution
I solved this problem by writing my own irequestmapper, which is just like the default, but the method maphandler () sets the protocol to HTTPS (if necessary)
final IRequestMapper o=getRootRequestMapper(); setRootRequestMapper(new IRequestMapper() { [...] @Override public Url mapHandler(IRequestHandler r) { Url u=o.mapHandler(r); if (condition) u.setProtocol("https"); return u; } });