What does the path get from the server by getRealPath () in jsp

女生的网名这么多〃 提交于 2019-12-02 14:08:48

First of all: getRealPath is deprecated. (compare: Interface ServletRequest). You should try this instead (since spec 2.1):

ServletContext context = session.getServletContext();
String realContextPath = context.getRealPath(request.getContextPath());

Earlier to this, it was highly depended on the server implementation. According to the spec it was allowed to return null if the application was deployed as a archived module (war, ear, etc.) I believe this never happened e.g. with WebLogic. It returned the path to the temp directory where the archives had been unpacked. So, to make a long answer short:

Your code will end up with something like this:

x:\your\path\on\drive\images\logos\somename.ext

It's not possible to use this as an image URL.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!