简体   繁体   中英

Custom servlet/jsp in Liferay portlet

I remember it was possible to add something like this to web.xml of a portlet and one could reach the jsp or servlet at http://host:8080/abcd/hw ....

<servlet>
    <servlet-name>myjsp</servlet-name>
    <jsp-file>/index.jsp</jsp-file>
    <init-param>
        <param-name>hello</param-name>
        <param-value>test</param-value>
    </init-param>
</servlet>
<servlet>
    <servlet-name>myServlet</servlet-name>
    <servlet-class>com.example.Servlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>myjsp</servlet-name>
    <url-pattern>/jsp/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>myServlet</servlet-name>
    <url-pattern>/abcd/hw</url-pattern>
    <load-on-startup>1</load-on-startup>
</servlet-mapping>

But now it kinda resolves into

INFO  [PortalImpl:4243] Current URL /abcd/hw generates exception: null

like if it was filtered away or something, but I haven't found anything when debugging it.

I smell the problem here

13:48:58,587 DEBUG [ETagFilter:116] [http-8080-1]> com.liferay.portal.servlet.filters.etag.ETagFilter /web/guest/abcd/hw
13:48:58,588 DEBUG [I18nFilter:116] [http-8080-1]=> com.liferay.portal.servlet.filters.i18n.I18nFilter /web/guest/abcd/hw
13:48:58,588 DEBUG [SecureFilter:118] Access allowed for 127.0.0.1
13:48:58,589 DEBUG [SecureFilter:138] https is not required
13:48:58,589 DEBUG [SecureFilter:172] Not securing http://localhost:8080/web/guest/abcd/hw
13:48:58,590 DEBUG [SecureFilter:116] [http-8080-1]==> com.liferay.portal.servlet.filters.secure.SecureFilter /web/guest/abcd/hw
13:48:58,645 INFO  [PortalImpl:4437] Current URL /abcd/hw generates exception: null
13:48:58,646 DEBUG [SecureFilter:118] Access allowed for 127.0.0.1
13:48:58,647 DEBUG [SecureFilter:138] https is not required
13:48:58,647 DEBUG [SecureFilter:172] Not securing http://localhost:8080/c/portal/status
13:48:58,648 DEBUG [SecureFilter:116] [http-8080-1]===> com.liferay.portal.servlet.filters.secure.SecureFilter /c/portal/status
13:48:58,649 DEBUG [MainServlet:359] Process service request

There is just one piece of information that you are not aware of.

The URL would be http://host:8080/cool-portlet/abcd/hw ....

if you are requesting a servlet, the 'web-context' directory name must follow ...

webapp/
    cool-portlet/
    ROOT/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM