Package COM. shop. uitl; import javax. servlet. HTTP. httpservletrequest; import Org. apache. struts2.servletactioncontext; public class serverurl {/*** get the basic URL of the Service * @ Param Request * @ return */public static string getserverpath (httpservletrequest request) {string Path = request. getcontextpath (); string basepath = request. getscheme () + ": //" + request. getservername () + ":" + request. getserverport () + path + "/"; return basepath ;} /*** get the URL address with a directory * @ Param Request * @ Param directory * @ return */public static string getserverpath (httpservletrequest request, string directory) {string Path = request. getcontextpath (); string basepath = request. getscheme () + ": //" + request. getservername () + ":" + request. getserverport () + path + "/"; return basepath + directory + "/";} /*** get the root path of the server * @ Param Request * @ Param directory * @ return */public static string getservercontextpath (httpservletrequest request) {string Path = request. getcontextpath (); return path;}/*** obtain the local disk path of the server * @ Param Request * @ return */public static string getdiskpath (httpservletrequest request) {string Path = servletactioncontext. getservletcontext (). getrealpath ("/"); return path;}/*** get the local disk path of the server, folder * @ Param Request * @ Param directory * @ return */public static string getdiskpath (httpservletrequest request, string directory) {string Path = servletactioncontext. getservletcontext (). getrealpath ("/"); Return Path + directory + "/";}}