How to support JSP file in two different locations with Spring boot?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
For some special reason, I have to support JSP files in two different locations.
Currently I wrote the following configuration:
@Configuration
public class JSPConfig {
@Bean
public InternalResourceViewResolver viewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setPrefix("/WEB-INF/webpage/");
viewResolver.setSuffix(".jsp");
viewResolver.setOrder(1);
return viewResolver;
}
@Bean
public InternalResourceViewResolver viewResolver2() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setPrefix("/webpage/");
viewResolver.setSuffix(".jsp");
viewResolver.setOrder(2);
return viewResolver;
}
}
But it does not work. The 1st InternalResourceViewResolver
is for JSP file in my project, it works without any problem. The 2nd one is for JSP file in one 3rd party jar with the following path {jarfilename}orgapachejspwebpagemodulesgen
. And the path for 3rd party jar file in final war file is {warfilename}WEB-INFlib
. I use the JSP file as modules/gen/{some_jsp_name_without_suffix}
in one controller. Unfortunately the JSP file in the 3rd can not be located.
Through debugging step by step, I noticed that the reason is that it never tries to locate and match the 2nd InternalResourceViewResolver
under current configuration. It tries to match the 1st view resolver, failed. It tries to match some .ftl
view resolver, failed.
Could any one give me a hand? Does Spring boot support locating JSP files under two different paths?
Thanks very much.
java spring jsp spring-boot
add a comment |
For some special reason, I have to support JSP files in two different locations.
Currently I wrote the following configuration:
@Configuration
public class JSPConfig {
@Bean
public InternalResourceViewResolver viewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setPrefix("/WEB-INF/webpage/");
viewResolver.setSuffix(".jsp");
viewResolver.setOrder(1);
return viewResolver;
}
@Bean
public InternalResourceViewResolver viewResolver2() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setPrefix("/webpage/");
viewResolver.setSuffix(".jsp");
viewResolver.setOrder(2);
return viewResolver;
}
}
But it does not work. The 1st InternalResourceViewResolver
is for JSP file in my project, it works without any problem. The 2nd one is for JSP file in one 3rd party jar with the following path {jarfilename}orgapachejspwebpagemodulesgen
. And the path for 3rd party jar file in final war file is {warfilename}WEB-INFlib
. I use the JSP file as modules/gen/{some_jsp_name_without_suffix}
in one controller. Unfortunately the JSP file in the 3rd can not be located.
Through debugging step by step, I noticed that the reason is that it never tries to locate and match the 2nd InternalResourceViewResolver
under current configuration. It tries to match the 1st view resolver, failed. It tries to match some .ftl
view resolver, failed.
Could any one give me a hand? Does Spring boot support locating JSP files under two different paths?
Thanks very much.
java spring jsp spring-boot
No it doesn't. And that has nothing to do with Spring Boot but how theUrlViewResovler
works internally.
– M. Deinum
Nov 22 '18 at 13:53
@M.Deinum you mean there is no way to work around?
– Jiang
Nov 22 '18 at 14:03
@Jiang Have you looked at the answer over here
– mallikarjun
Nov 22 '18 at 14:14
You could extend theInternalResourceViewResolver
and check if the actual resolved URL would exist. But this could be very bad for performance.
– M. Deinum
Nov 22 '18 at 14:31
add a comment |
For some special reason, I have to support JSP files in two different locations.
Currently I wrote the following configuration:
@Configuration
public class JSPConfig {
@Bean
public InternalResourceViewResolver viewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setPrefix("/WEB-INF/webpage/");
viewResolver.setSuffix(".jsp");
viewResolver.setOrder(1);
return viewResolver;
}
@Bean
public InternalResourceViewResolver viewResolver2() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setPrefix("/webpage/");
viewResolver.setSuffix(".jsp");
viewResolver.setOrder(2);
return viewResolver;
}
}
But it does not work. The 1st InternalResourceViewResolver
is for JSP file in my project, it works without any problem. The 2nd one is for JSP file in one 3rd party jar with the following path {jarfilename}orgapachejspwebpagemodulesgen
. And the path for 3rd party jar file in final war file is {warfilename}WEB-INFlib
. I use the JSP file as modules/gen/{some_jsp_name_without_suffix}
in one controller. Unfortunately the JSP file in the 3rd can not be located.
Through debugging step by step, I noticed that the reason is that it never tries to locate and match the 2nd InternalResourceViewResolver
under current configuration. It tries to match the 1st view resolver, failed. It tries to match some .ftl
view resolver, failed.
Could any one give me a hand? Does Spring boot support locating JSP files under two different paths?
Thanks very much.
java spring jsp spring-boot
For some special reason, I have to support JSP files in two different locations.
Currently I wrote the following configuration:
@Configuration
public class JSPConfig {
@Bean
public InternalResourceViewResolver viewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setPrefix("/WEB-INF/webpage/");
viewResolver.setSuffix(".jsp");
viewResolver.setOrder(1);
return viewResolver;
}
@Bean
public InternalResourceViewResolver viewResolver2() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setPrefix("/webpage/");
viewResolver.setSuffix(".jsp");
viewResolver.setOrder(2);
return viewResolver;
}
}
But it does not work. The 1st InternalResourceViewResolver
is for JSP file in my project, it works without any problem. The 2nd one is for JSP file in one 3rd party jar with the following path {jarfilename}orgapachejspwebpagemodulesgen
. And the path for 3rd party jar file in final war file is {warfilename}WEB-INFlib
. I use the JSP file as modules/gen/{some_jsp_name_without_suffix}
in one controller. Unfortunately the JSP file in the 3rd can not be located.
Through debugging step by step, I noticed that the reason is that it never tries to locate and match the 2nd InternalResourceViewResolver
under current configuration. It tries to match the 1st view resolver, failed. It tries to match some .ftl
view resolver, failed.
Could any one give me a hand? Does Spring boot support locating JSP files under two different paths?
Thanks very much.
java spring jsp spring-boot
java spring jsp spring-boot
edited Nov 22 '18 at 13:45
ygor
1,1521616
1,1521616
asked Nov 22 '18 at 13:14
JiangJiang
1
1
No it doesn't. And that has nothing to do with Spring Boot but how theUrlViewResovler
works internally.
– M. Deinum
Nov 22 '18 at 13:53
@M.Deinum you mean there is no way to work around?
– Jiang
Nov 22 '18 at 14:03
@Jiang Have you looked at the answer over here
– mallikarjun
Nov 22 '18 at 14:14
You could extend theInternalResourceViewResolver
and check if the actual resolved URL would exist. But this could be very bad for performance.
– M. Deinum
Nov 22 '18 at 14:31
add a comment |
No it doesn't. And that has nothing to do with Spring Boot but how theUrlViewResovler
works internally.
– M. Deinum
Nov 22 '18 at 13:53
@M.Deinum you mean there is no way to work around?
– Jiang
Nov 22 '18 at 14:03
@Jiang Have you looked at the answer over here
– mallikarjun
Nov 22 '18 at 14:14
You could extend theInternalResourceViewResolver
and check if the actual resolved URL would exist. But this could be very bad for performance.
– M. Deinum
Nov 22 '18 at 14:31
No it doesn't. And that has nothing to do with Spring Boot but how the
UrlViewResovler
works internally.– M. Deinum
Nov 22 '18 at 13:53
No it doesn't. And that has nothing to do with Spring Boot but how the
UrlViewResovler
works internally.– M. Deinum
Nov 22 '18 at 13:53
@M.Deinum you mean there is no way to work around?
– Jiang
Nov 22 '18 at 14:03
@M.Deinum you mean there is no way to work around?
– Jiang
Nov 22 '18 at 14:03
@Jiang Have you looked at the answer over here
– mallikarjun
Nov 22 '18 at 14:14
@Jiang Have you looked at the answer over here
– mallikarjun
Nov 22 '18 at 14:14
You could extend the
InternalResourceViewResolver
and check if the actual resolved URL would exist. But this could be very bad for performance.– M. Deinum
Nov 22 '18 at 14:31
You could extend the
InternalResourceViewResolver
and check if the actual resolved URL would exist. But this could be very bad for performance.– M. Deinum
Nov 22 '18 at 14:31
add a comment |
0
active
oldest
votes
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%2f53431836%2fhow-to-support-jsp-file-in-two-different-locations-with-spring-boot%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f53431836%2fhow-to-support-jsp-file-in-two-different-locations-with-spring-boot%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
No it doesn't. And that has nothing to do with Spring Boot but how the
UrlViewResovler
works internally.– M. Deinum
Nov 22 '18 at 13:53
@M.Deinum you mean there is no way to work around?
– Jiang
Nov 22 '18 at 14:03
@Jiang Have you looked at the answer over here
– mallikarjun
Nov 22 '18 at 14:14
You could extend the
InternalResourceViewResolver
and check if the actual resolved URL would exist. But this could be very bad for performance.– M. Deinum
Nov 22 '18 at 14:31