Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Context path after dispath view.jsp not correct in liferay DXP
I am using spring MVC with gwt which need dispath to view.jsp and then it push frontend to redirect and it will download some file from server to load the page, but the file context path not correct after deploy to liferay DXP.
The find path should be like that
https://<hostname>/<context path>/<source folder>/xxxxxxxxxxxx.cache.js
but after deploy to liferay DXP change to like this
https://<hostname>/xxxxxxxxxxxx.cache.js
I know that after liferay DXP the file path should change to below and I try to get the file successful by using this path but how can I change the context path under liferay DXP
https://<hostname>/o/<context path>/<source folder>/xxxxxxxxxxxx.cache.js
GenericPortlet.java
@Override
protected void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
request.setAttribute("DEFAULT_RENDER_URL", response.createRenderURL().toString());
response.setContentType(request.getResponseContentType());
String url = "/WEB-INF/jsp/view.jsp";
getPortletContext().getRequestDispatcher(url).include(request, response);
}
The find path should be like that
https://<hostname>/<context path>/<source folder>/xxxxxxxxxxxx.cache.js
but after deploy to liferay DXP change to like this
https://<hostname>/xxxxxxxxxxxx.cache.js
I know that after liferay DXP the file path should change to below and I try to get the file successful by using this path but how can I change the context path under liferay DXP
https://<hostname>/o/<context path>/<source folder>/xxxxxxxxxxxx.cache.js
GenericPortlet.java
@Override
protected void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
request.setAttribute("DEFAULT_RENDER_URL", response.createRenderURL().toString());
response.setContentType(request.getResponseContentType());
String url = "/WEB-INF/jsp/view.jsp";
getPortletContext().getRequestDispatcher(url).include(request, response);
}
You can change the /o to something else, but you cannot get rid of the /o.
Normally to accommodate something like this I like to use a rewrite rule in apache or nginx to take the incoming URL that you want to do and send it to the URL that Liferay expects. It's the best way to keep what you need yet live with what Liferay requires.
Normally to accommodate something like this I like to use a rewrite rule in apache or nginx to take the incoming URL that you want to do and send it to the URL that Liferay expects. It's the best way to keep what you need yet live with what Liferay requires.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™