M
M
Mikhail Voitenko2014-07-21 15:06:31
Java
Mikhail Voitenko, 2014-07-21 15:06:31

HTML images in HTMLPanel?

There is a problem. for example i have an html file Description.htmland it contains something like

<p>
    <img src="Bill.jpg">
</p>

Bill.jpg lies nearby, in the same folder as the html file.
there is also a UiBinder widget which contains a SimplePanel named panel . In ui.xml for this widget:
...
<ui:style src="../Style.css"/>

    <g:SimplePanel ui:field="panel" addStyleNames="{style.description}" />
...

Widget constructor:
public SomeWidget() {
        initWidget(uiBinder.createAndBindUi(this));
        panel.setWidget(new HTMLPanel(HtmlTextResources.htmlFile().getText());
    }

The essence of the problem - bill.img is not displayed . Console writes:
> [WARN] 404 - GET /bill.jpg (127.0.0.1) 1373 bytes Request headers
> Host: 127.0.0.1:8888
> Connection: keep-alive
> Cache-Control: no-cache
> Accept: image/webp,* /*;q=0.8
> Pragma: no-cache
> User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153
> Safari/537.36
> **** ***************
> Accept-Encoding: gzip,deflate,sdch
> Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q= 0.4,it;q=0.2,uk;q=0.2 Response
> headers
> Content-Type: text/html;charset=ISO-8859-1
> Cache-Control: must-revalidate,no-cache,no-store
>content length: 1373

How can this be fixed? Pictures should use it through html.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mikhail Voitenko, 2014-07-21
@Firehanded

As it turned out, it was necessary to create the images package in the webApp and copy the image into it, and register <img src="../images/Bill.jpg">
AND clear the cache, otherwise the image was not immediately displayed.

V
Vitaly Kirenkov, 2014-07-21
@DeLaVega

What do you mean it's not displayed? Does the code show up on the page? If yes, is the path correct? Maybe you're just missing a slash at the beginning?

A
Alexander Borisovich, 2014-07-21
@Alexufo

Bill.jpg lies nearby, in the same folder as the html file.

Yes, if the main page connects it through the 4th template, it will think that the file is at the root, and not next to your file.
You have 404. You either need to insert some variable of your template engine so that the path to the picture is working, or something else to pick with the paths.
The web server has a virtual environment. Does not match up to a certain level with your file system.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question