Spring Boot Changing Values From a Controller To Another
I'm having an issue with 2 controllers and i'm not sure if there is a solution for this.
I extract some ads from the internet(thousands of ads) and i can't extract all of them at once because it will take too long to load all those ads on the page.
Basically the first controller is a POST controller which returns always let's say the first 5 elements from that list and it looks like this:
@RequestMapping(value = "/search1" , method = RequestMethod.POST)
public List search1(){
List<?> list1 = scrapper1.search1():
return list1;
}
The second controller returns the next 5 elements per execution(until the end of the list and then it starts from the first 5 elements) from the same list but it's a different method, let's say this controller looks like this:
@RequestMapping(value = "/search2", method = RequestMethod.POST)
public List search2(){
List<?> list2 = scrapper2.search2();
return list2;
}
My problem is that if the second method is executed let's say 3 times the page will contain elements from that list which are from 10-15 and if the first method gets executed again the page will contain elements from 0-5 but now if the second method gets executed it will jump to elements from 15-20.I need those 2 controllers because i have 2 buttons on the page and there are multiple lists..I need somehow to reset the second method whenever the first method from the first controller gets executed.Are there any ways to do this?
java algorithm controller
add a comment |
I'm having an issue with 2 controllers and i'm not sure if there is a solution for this.
I extract some ads from the internet(thousands of ads) and i can't extract all of them at once because it will take too long to load all those ads on the page.
Basically the first controller is a POST controller which returns always let's say the first 5 elements from that list and it looks like this:
@RequestMapping(value = "/search1" , method = RequestMethod.POST)
public List search1(){
List<?> list1 = scrapper1.search1():
return list1;
}
The second controller returns the next 5 elements per execution(until the end of the list and then it starts from the first 5 elements) from the same list but it's a different method, let's say this controller looks like this:
@RequestMapping(value = "/search2", method = RequestMethod.POST)
public List search2(){
List<?> list2 = scrapper2.search2();
return list2;
}
My problem is that if the second method is executed let's say 3 times the page will contain elements from that list which are from 10-15 and if the first method gets executed again the page will contain elements from 0-5 but now if the second method gets executed it will jump to elements from 15-20.I need those 2 controllers because i have 2 buttons on the page and there are multiple lists..I need somehow to reset the second method whenever the first method from the first controller gets executed.Are there any ways to do this?
java algorithm controller
add a comment |
I'm having an issue with 2 controllers and i'm not sure if there is a solution for this.
I extract some ads from the internet(thousands of ads) and i can't extract all of them at once because it will take too long to load all those ads on the page.
Basically the first controller is a POST controller which returns always let's say the first 5 elements from that list and it looks like this:
@RequestMapping(value = "/search1" , method = RequestMethod.POST)
public List search1(){
List<?> list1 = scrapper1.search1():
return list1;
}
The second controller returns the next 5 elements per execution(until the end of the list and then it starts from the first 5 elements) from the same list but it's a different method, let's say this controller looks like this:
@RequestMapping(value = "/search2", method = RequestMethod.POST)
public List search2(){
List<?> list2 = scrapper2.search2();
return list2;
}
My problem is that if the second method is executed let's say 3 times the page will contain elements from that list which are from 10-15 and if the first method gets executed again the page will contain elements from 0-5 but now if the second method gets executed it will jump to elements from 15-20.I need those 2 controllers because i have 2 buttons on the page and there are multiple lists..I need somehow to reset the second method whenever the first method from the first controller gets executed.Are there any ways to do this?
java algorithm controller
I'm having an issue with 2 controllers and i'm not sure if there is a solution for this.
I extract some ads from the internet(thousands of ads) and i can't extract all of them at once because it will take too long to load all those ads on the page.
Basically the first controller is a POST controller which returns always let's say the first 5 elements from that list and it looks like this:
@RequestMapping(value = "/search1" , method = RequestMethod.POST)
public List search1(){
List<?> list1 = scrapper1.search1():
return list1;
}
The second controller returns the next 5 elements per execution(until the end of the list and then it starts from the first 5 elements) from the same list but it's a different method, let's say this controller looks like this:
@RequestMapping(value = "/search2", method = RequestMethod.POST)
public List search2(){
List<?> list2 = scrapper2.search2();
return list2;
}
My problem is that if the second method is executed let's say 3 times the page will contain elements from that list which are from 10-15 and if the first method gets executed again the page will contain elements from 0-5 but now if the second method gets executed it will jump to elements from 15-20.I need those 2 controllers because i have 2 buttons on the page and there are multiple lists..I need somehow to reset the second method whenever the first method from the first controller gets executed.Are there any ways to do this?
java algorithm controller
java algorithm controller
asked Nov 21 '18 at 19:14
Truica SorinTruica Sorin
737
737
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
For this type of problem we can use PagingAndSortingRepository from spring data.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419075%2fspring-boot-changing-values-from-a-controller-to-another%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
For this type of problem we can use PagingAndSortingRepository from spring data.
add a comment |
For this type of problem we can use PagingAndSortingRepository from spring data.
add a comment |
For this type of problem we can use PagingAndSortingRepository from spring data.
For this type of problem we can use PagingAndSortingRepository from spring data.
answered Nov 21 '18 at 19:52
jogendrajogendra
945
945
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419075%2fspring-boot-changing-values-from-a-controller-to-another%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown