Why does servletContext.getRealPath returns null o

2019-02-17 00:01发布

I have the following code line:

servletContext.getRealPath("resources/images/video_icon.png")

Wen I run application using jetty(using maven plugin) this code line return corect value.

When I run application using tomcat 8(on tomcat 7 it works) - application returns null.

application structure:

enter image description here

1.How to fix it?
2.Why does it happen?

1条回答
再贱就再见
2楼-- · 2019-02-17 00:54

after adding / in the path beginning it works for both: jetty and tomcat 8

servletContext.getRealPath("/resources/images/video_icon.png")
查看更多
登录 后发表回答