0

我有一个图片库,当我将鼠标悬停在任何图片上时,图片会拉回来,露出一些文字。

当我在 HTML 文档中有以下 HTML 代码(在帖子底部)时,一切正常。

但是,当我将完全相同的 HTML 代码放入 Java servlet 并将其返回到页面时,一切看起来都很正常,但图像回调不再起作用。

知道为什么会发生这种情况吗?也许我需要进行某种刷新以使其正常工作?

图库中一项的相关代码:

  <li>
           <div class="header"><p><a href="product.jsp">Product 1 Shirt</a></p></div>
           <div class="gallery_item">
                    <img src="gallery/thumb/gallery_01.jpg" width="214" height="194" class="cover" alt="" />                        
                    <p>Highlight 1</p>
                    <p>Highlight 2</p>
                    <p>Highlight 3</p>
                    <a href="product.jsp" class="btn alignleft" title="More Info">More Info</a>                                               
                    <a href="gallery/fullsize/gallery_01.jpg" class="zoom" data-rel="prettyPhoto[gallery1]">Enlarge</a>                                                                    
                    <a href="gallery/fullsize/gallery_02.jpg" data-rel="prettyPhoto[gallery1]"></a>
           </div>
           <div class="p2"><p>Price: $10</p></div>
           <div class="p2"><p>In Stock: Yes</p></div>              

    </li>

根据要求:servlet:

  public void service(HttpServletRequest request,
        HttpServletResponse response) throws IOException,
        ServletException
{
    PrintWriter out = response.getWriter();
    response.setContentType("text/html");
    String requestType = request.getParameter("type");
    String result;

    if(requestType.equals("getproductlist"))
    {
        Products products = Products.getProductsInstance();
        String keywords = request.getParameter(("keywords"));
        String organization = request.getParameter(("organization"));
        String price = request.getParameter(("price"));
        String sort = request.getParameter(("sort"));

        result = products.getProducts(keywords, organization, price, sort);

//this next lines of html are actually what is returned from products.getProducts. I'm just putting it here for clarity. All the variables (name, h1, etc) are okay.

        result += "<li>"
                    + "<div class=\"header\"><p><a href=\"product.jsp\">"+ name +"</a></p></div>"
                    + "<div class=\"gallery_item\">"
                    + "<img src=\"gallery/thumb/gallery_01.jpg\" width=\"214\" height=\"194\" class=\"cover\" alt=\"\" />"
                    + "<p>"+ h1 +"</p>"
                    + "<p>"+ h2 +"</p>"
                    + "<p>"+ h3 +"</p>"
                    + "<a href=\"product.jsp\" class=\"btn alignleft\" title=\"More Info\">More Info</a>"
                    + "<a href=\"gallery/fullsize/gallery_01.jpg\" class=\"zoom\" data-rel=\"prettyPhoto[gallery1]\">Enlarge</a> "
                    + "<a href=\"gallery/fullsize/gallery_02.jpg\" data-rel=\"prettyPhoto[gallery1]\"></a>"
                    + "</div>"
                    + "<div class=\"p2\"><p>Price: "+ itemPrice +"</p></div>"
                    + "<div class=\"p2\"><p>In Stock: "+ inStock +"</p></div>   "
                    + "</li>";


        out.println(result);
        out.close();

    }
4

0 回答 0