我有Struts 2的一个小问题,当我试图让上下文路径:如何在Struts 2中获取实际的源代码路径?
ServletActionContext.getServletContext().getRealPath("\\WebContent\\resources\\img\\");
我得到这个路径:
C:\用户\基利安\ workspace.metadata.plugins \ org.eclipse.wst.server.core \ tmp0 \ wtpwebapps \ SiteWebAdministrable \ WebContent \ resources \ imgicone.jpg
为什么确切的源代码路径?
因为我需要上载并保存管理网站的图片来控制背景,并且没有实际的路径,我无法将图片保存在资源路径中...... 因此,我将名称和扩展名保存在数据库中没问题),我需要将图像保存在资源目录(图像问题...)
有人可以帮我吗?我忘了什么吗?
这个问题是答案吗?
How do you get the project path in Struts 2?
你的路径有什么问题? –
我搜索类似C:\ Users \ killian \ workspace \ SiteWebAdministrable \ WebContent \ resources \ img \ icone.jpg的路径将图像保存在项目目录中 –