简体   繁体   English

在jsp中渲染图像的问题

[英]issues with rendering image in jsp

I am not able to render the image inside the jsp. 我无法在jsp中渲染图像。 Everything else is working fine ie all the data is being renderred. 其他一切工作正常,即所有数据都被渲染。 its only the image which is causing the issue. 它只是导致问题的图像。 And I know the path is correct 而且我知道这条路是正确的

<img src="https://localhost/genesis/images/client-logo1.png" alt="Image not available">

or 要么

<img src="/images/client-logo1.png" alt="Image not available">

The below code renders the jsp 下面的代码呈现了jsp

HttpServletResponse charResponse = null;
     Locale locale = ProxyContextHolder.getProxyContext().getLocale();
    try {
        View view = jspViewResolver.resolveViewName(viewNameWithExtension , locale);
        StringWriter sw = new StringWriter();
        Object request = (ProxyContextHolder.getProxyContext()).getRequest();
        Object response = (ProxyContextHolder.getProxyContext()).getResponse();
        if (request != null &&  request instanceof HttpServletRequest
            && response != null &&  response instanceof HttpServletResponse) {
            HttpServletRequest httpReq = (HttpServletRequest) request;
            HttpServletResponse httpResp = (HttpServletResponse) response;
            charResponse = new CharResponseWrapper(httpResp);
            view.render(modelMap, httpReq, charResponse);
            html = charResponse.toString();
            //httpReq.getRequestDispatcher(viewNameWithExtension).include(httpReq, charResponse);
           // html = charResponse.toString();
        }
    }

i have tried a few approach but nothing seems to be working. 我尝试了一些方法,但似乎没有任何效果。 The jsp is loaded into a jeditorPane and an image is created from it. 将jsp加载到jeditorPane中,并从中创建图像。

At max i can see is some sort of broken or unrenderred image with a sun and mountain... not sure what it is 在最大程度上,我可以看到带有太阳和山脉的某种破碎或未渲染的图像……不确定是什么

Can someone please help me out with this? 有人可以帮我这个忙吗?

Is the /image prefix resolved by the code you listed for jsp ? / image前缀是否由您为jsp列出的代码解析? I think it should be left alone... 我认为应该让它单独...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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