简体   繁体   中英

GlassFish 4 alternatedoc doesn't work

I am trying to reach an external folder using alternatedoc but it doesn't work. I put images in C:/users/salih/downloads and mapped images folder to this folder, but i couldn't make it work.

Here is glassfish-web.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app error-url="">
  <resource-ref>
    <res-ref-name>jdbc/mysql</res-ref-name>
    <jndi-name>jdbc/mysql</jndi-name>
  </resource-ref> 
   <context-root>/Shiro</context-root>
      <property name="alternatedocroot_1" value="from=/images/* dir=c:/users/salih/downloads" description="Uploaded Images"/>
</glassfish-web-app>

Here is the page where i try to access an image under c:/users/salih/downloads

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        Photo Detail
        <img src="images/adevices8.png" width="34" height="34"/>
    </h:body>
</html>

The mapping is maybe a bit unintuitive. You need to put the images in

c:/users/salih/downloads/images/

If u define your docroot like that

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM