开发者

Image path formatting

I'm trying to put an image to pdf file in 开发者_运维百科my spring application. The code is

URL imageUrl = getClass().getResource(LOGO_PATH);
        Image logo = Image.getInstance(imageUrl);

I have the image in source packages in com.application.pdf -package. How do I reference to LOGO_PATH then?

private static final String LOGO_PATH = "/src/java/com/application/pdf/logo.gif";

gives me null pointerexception.


You are tried to find resource in src folder, but in runtime you have to get resource from other folder, compile folder ( for example resource ) or from jar file, try to change your path to compile folder and I think all will be ok. UPDATE Could you provide structure of your application and I will help you to write correct path?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜