java - Create link to a resource file in the browser -
good evening!
i developing small rest server in spring. faced following problem:
i need open resource folder , send link files of following form:
http: // localhost: 8080 / myprojectname / resurses / 2.jpg
but take type of link:
file: / d: /apache-tomcat-7.0.69/webapps/root/web-inf/classes/2.jpg
the dispatcher-servlet.xml file added:
<mvc: resources mapping = "/ resources / **" location = "/ resources /" />
in controller declared method:
@requestmapping("/get_photo") public @responsebody requestuserinfofull get_photo(@requestbody string body, httpservletrequest request, httpservletresponse response) throws ioexception { requestuserinfofull result = new requestuserinfofull(); userfullinformation usf = new userfullinformation(); resource anotherresource =context.getresource("2.jpg"); usf.setphoto(anotherresource.geturl()); result.setprofile(usf); return result;
please problem. grateful. sorry english. terrible. , code not best .. started learning spring :)
my problem in inccorrect spring dispatcher configuration , folder structure.
<mvc:resources mapping="/resources/**" location="/resources/" />
Comments
Post a Comment