2014年5月22日星期四

jsp how to read the absolute path to the temporary folder under tomcat temp under the picture ?

jsp how to read the absolute path to the temporary folder under tomcat temp under the picture ?
-------------
because access is very large, temporary images generated more thought put under temporary folder under tomcat temp, easy to clean up regularly .
------ Solution ---------------------------------------- ----
xxx.class.getResource ("/") to get the root directory of the project , the rest of their own to fight it
------ Solution -------- ------------------------------------
in jsp do this:
request.getContentPath () to get the project root directory. If your path is in the root directory , it is this:
String tmpPath = request.getContentPath () + "/ temp";
then traverse the path of the file to obtain the desired picture.
------ Solution ---------------------------------------- ----
your temporary path is up to you to set up.
Then , you can use this as a path you want to take .
------ Solution ---------------------------------------- ---- before
entangled in this you how to write this path
I want to emphasize is :
redirection when the imp jsp loaded the default root directory is redirected Tomcat server the root
respon.sendRedirect ("/") ;/ / this is the root directory of the Tomcat

hope useful ! ! ! !
------ Solution ---------------------------------------- ----
read the display , is a simple stream operations
------ Solution ------------------------ --------------------
these documents you need to protect it? If you do not need an alias such as tomcat Riga

<Context path="/temp" docBase="e:/tomcat/temp"  crossContext="false"  debug="1"  reloadable="true" >      
</Context>


then the tag in your img src can write
<img src="/temp/toto.png"/>

------ For reference only ----------------------------------- ----
not project root
------ For reference only --------------------------- ------------
My pictures have been placed in temporary temp file folder under tomcat , and now is how to use this image in jsp page , absolute path to use, the picture does not show . Is there any way ?
------ For reference only -------------------------------------- -

My pictures have been placed in temp folder , and that is the root directory of tomcat , I 've got to use it! My worry now is how to read the displayed ~ ~
------ For reference only -------------------------- -------------

now use to configure a virtual directory Photo 'd come out, the configuration of how regularly cleaned
------ For reference only ------------------ ---------------------
ah , but I have written to the specified folder of images , but the src = "", can not be displayed , and the path is correct, there is no split image placeholder is not properly displayed , search the search are saying , do not understand ~ ~
------ For reference only -------- -------------------------------
src = "/ application name / image path " , put your catalog made up .
------ For reference only -------------------------------------- -
currently is so resolved , thank you
------ For reference only -------------------------- -------------
your landlord is how to solve the country. Path picture I uploaded is stored in the database / uploadfile/Document/38f78d6e-35c3-424b-8255-f505e74a656f.jpg I can picture how drawn out of it in jsp interface display . Solving

没有评论:

发表评论