How to use HttpSerletRequest in Spring Boot 2.x? - spring-boot

Please help me!
I can edit the URL of the page like "?key=value", then reload the page and see the result. But how to set params and reload when clicking on a tag?
<option value=""><a th:href="${'/?&sortByPrice=ASC'}">Giá từ thấp đến cao</a></option>

you put the wrong symbols in the URl.
you should use ? with the fist key/value and then use the &
Like this
/?sortByPrice=ASC&sortByvalue=none
OR
/abcd?sortByPrice=ASC&sortByvalue=none`

Related

Alipay post URL when click on order submit

Which parameters are needed to build a Alipay post URL ?
Currently using https://openapi.alipaydev.com/gateway.do? as a test URL and service is service=create_forex_trade
I think you need to add following parameters
openapi is used for testing purpose while mapi.alipay.net is used for actual transaction purpose
https://openapi.alipaydev.com/gateway.do?_input_charset=utf-8
body={ordernumber}
currency={AUD}
notify_url={notify_url}
out_trade_no={}
partner={partner_id}
price=1395
quantity=1
return_url={return_url}
service=trade_create_by_buyer
sign={encryption_sign_key}
sign_type=MD5

How to Auto generate URL based on attribute Route Url in Help page in WebApI

I am trying to display the Help page in WebApi, by displaying the URL and corresponding parameters.
By using the following command in "Package Manager Console" I am able to generate Help page with basic GET, POST, PUT, DELETE verbs (it using the simple operations).
PM> Install-Package Microsoft.AspNet.WebApi.HelpPage
I done this using the following explanary link: http://www.asp.net/web-api/overview/creating-web-apis/creating-api-help-pages and it is showing URL help like this : " GET api/Values "
But in my application I am using the "Attribute Route" Concept for accessing URL in the service, like:
[ActionName("TestGet")]
[Route("TestApi/TestGet/{Value}")]
public string TestGetting(int Value)
{
return Value.ToString();
}
for showing the attribute Route URL in help page automatically, like :" Get TestApi/TestGet/{Value} "
What should I have to do?
Please suggest the better answer/links to show the help Content dynamically.
Like Kiran says, this should just work if you enabled attribute routing.
Can you hit your action?
You should also remove the ActionName attribute as it's meaningless when you use attribute routing.

After Wicket session timeout - pageParameters are null

I'm using wicket 6.
My application is based on WebPages created with pageParameters in the constructor. I'm using also a pageParameter country that is a path-parameter defined with:
mountPage("/${country}/pagepath", MyPage.class);
I have many statefull forms in every page.
I'm now trying to handle the case when the session expires (to reproduce this scenario I delete or modify the jsessionid cookie).
After that I click a submit button in a page and I'd expect wicket to understand that the session has expired.
But the behaviour that I have is this:
the current page is reloaded but the pageparameters are 'null'
the url is rewritten using the package notation like:
localhost:8080/wicket/bookmarkable/com.test.pages.MyPage
So it looks like the url mapping is somehow lost.
I need to reload the same page with pageParameters information or show an info page that says something like click here to reload.
I've already tried to use:
getApplicationSettings().setPageExpiredErrorPage(HomePage.class);
but that didn't help.
Any help is appreciated. Thanks.
Looks like there is a bug in Wicket 6 which causes this issue: https://issues.apache.org/jira/browse/WICKET-5068
It is fixed in Wicket 7. For Wicket 6, there is a workaround: disable WICKET-4594 fix.
First add the following mapper:
public class BookmarkableMapperThatSavesPageParametersForListener extends BookmarkableMapper {
#Override
protected PageParameters getPageParametersForListener(PageInfo pageInfo, PageParameters pageParameters) {
return pageParameters;
}
}
Then use it to replace a built-in BookmarkableMapper in your Application#init() (this has to be added before any manipulations with the root mapper):
mount(new BookmarkableMapperThatSavesPageParametersForListener());
This approach works in our application and it does not seem to break anything.
More info: Wicket 6: empty PageParameters when recreating a page after expiration
You could ask your question in the wicket mailing list. What you are observing might be a bug. Please check PageParameters missing from re-created Page
Conceptually, it should be possible to submit the form normally even if you need an authenticated user session.
If the session is expired then you may be able to re-create a user session with a remember-me cookie. Wicket should re-construct the page with parameters, apply the form values and process the submit. In case where the page is stateful, there could be some complications that are possibly resolvable. If you find that your use case is not supported with stateful pages then you could file an issue and meanwhile use StatelessForm.

Grails Ajax Login

I want to take use of the ajax login feature of the spring security plugin.
I am completely stuck getting a JSON success response from the loginController into my GWT client.
As I understood from the documentation I need to post my params to the url /j_spring_security_check and spring security is redirecting me to the right action.
If I look into my LoginController I see nothing of the actual login logic and its a bit magic for me where all the login/db stuff is done. Further spring security always redirects to action auth instead of using AjaxAuth even if I add the header "X-Requested-With" to post. If I do my post to the url /login/ajaxAuth I am getting a 401 which is OK because its written down in the controller(even if i dont know why we need to return a 401 here). Maybe I am doing something completely wrong :-)
My basic questions are:
Where can I find the login logic?
What parameter do I have to provide?
Which URL do I have to use?
What do I have to do if I dont want to use the username but instead and email field?
Thanks for all your help!
Looks like you're correctly implemented it, maybe there some small bug, like a typo.
Btw:
It's implemented at filter, that process your request before actual controllers. At your case it will be UsernamePasswordAuthenticationFilter (or RequestHolderAuthenticationFilter). Controller is used there only to render an additional data. As for ajax auth, it uses /login/ajaxSuccess, that renders a JSON response
By default it uses j_username & j_password. And you can use ajax=true parameter, instead of X-Request-With header
/j_spring_security_check by default
You can implement your own GrailsUserDetailsService (or extend GormUserDetailsService), and setup it as a spring bean, with name userDetailsService, at resources.xml
You can also turn on logging for Spring Security by:
log4j {
debug 'org.codehaus.groovy.grails.plugins.springsecurity',
'org.springframework.security'
}
maybe it will be helpful
I am using Grails 2.1.1 and ran into this same issue. Tried all the above things but still couldnt get my AJAX login to call the ajaxSuccess method.
However when it failed it was calling authFail?ajax=true.
After digging in more, here is what I did:
Added grails.plugins.springsecurity.successHandler.targetUrlParameter = 'ajaxUrl' in my Config.groovy
Added <input type="hidden" name="ajaxUrl" value="/login/ajaxSuccess" /> in my AJAX login form
Not sure why it fixed, but it seemed to work for me.
Just posting this solution for users who get stuck and come to this ticket for solution.

How to check an Ajax request in cakephp?

How to check an Ajax request in cakephp?
Depends on the version of cake.
1.3.x:
$this->RequestHandler->isAjax();
2.x || 3.x
$this->request->is('ajax');
You need to enable the RequestHandler component
var $components = array('RequestHandler');
Then you check if its an ajax request in your controllers with:
$this->RequestHandler->isAjax()
You can find more information about the RequestHandler component here
this question is an older one but just in case anyone comes across this like me and uses CakePHP 2:
RequestHandler::isAjax() is deprecated, use the Request Object's $this->request->is('ajax');
More info here
Without the use of components you can use something like this:
$this->params['isAjax'];
This will return a bool.
this is the way whisch is described is doc.I have been using since i started using cakephp
if($this->RequestHandler->isAjax()){
//
}
If you simply want to check the function of the php side, try:
$this->log('some debug',LOG_DEBUG);
then check app/tmp/logs/debug.log.

Resources