小编Ade*_*eel的帖子

将空对象转换为整数

我试图理解以下代码。第2行输出null,而第3行抛出NullPointerException。我想念什么?从理论上讲,它应该起作用。

public static void main(String []args){

  1  Object[] obj = {null}; 
  2  System.out.println((Integer)obj[0]);  //Output null

  3  Integer n = obj[0] == null ? (Integer)obj[0] : 1; //NullPointerException
  4  System.out.println(n);
 }
Run Code Online (Sandbox Code Playgroud)

java nullpointerexception

5
推荐指数
1
解决办法
90
查看次数

如何在模态弹出窗口中显示 JSP 页面?

我对 Jsp 的东西很陌生。我想要实现的是在 service.jsp 页面中显示另一个 jsp 页面的内容让我们说 help.jsp 但仅当用户单击时?图像(?图像代表帮助)。我想在弹出窗口中显示 help.jsp 的内容,同时还希望主屏幕淡出或非棘手。

这是我目前正在做的事情。我在 service.jsp 中创建了一个 div

<div id="dialog" title="Basic dialog">

</div>
Run Code Online (Sandbox Code Playgroud)

并创建了一个 javascript 函数

function openDialog() {
        $("#dialog").load('/myaccount/registration/help.jsp').dialog({modal: true});
    }
Run Code Online (Sandbox Code Playgroud)

我的锚标签看起来像这样

 <a tabindex="1005" href="#"  onclick="openDialog();" onMouseOver="window.status='Launch Help Window'; return true" onMouseOut ="window.status='';return true"><span class="WhiteBody"><img src="images/icon_help.gif" border="0"></span></a>
Run Code Online (Sandbox Code Playgroud)

当我单击帮助按钮时,它会重定向到一个空白页面。

请帮我 !

html javascript java jquery jsp

3
推荐指数
1
解决办法
3万
查看次数

简单的文件删除代码在 Java 中不起作用

这是我删除pdf文件的代码

try {
    File file = new File(docObjectId + ".pdf");
    file.setWritable(true);
    System.out.println(file.length());
    if (file.delete()) {
        System.out.println(file.getName() + " is deleted!");
    } else {
        System.out.println("Delete operation is failed.");
    }
} catch (Exception e) {
    e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)

它转到代码的 else 部分。

PDF 文件位于项目根文件夹中,我可以手动删除它。现在抓我的头。

这里是完整的方法。这可能是由于其他一些原因

public Response getContractDocument(@PathParam("docid") String docObjectId) throws Exception {
    DocumentumService documentumService = new DocumentumService(documentumConfigUtil);
    DocumentumDocumentBean docDocumentBean = documentumService.getContractDocContent(docObjectId, true);

    FileInputStream fileInputStream;
    fileInputStream = new FileInputStream(docDocumentBean.getDocFile());
    compressPdf(fileInputStream,docObjectId + ".pdf");

    fileInputStream = new FileInputStream(docObjectId + ".pdf");


    ResponseBuilder responseBuilder = Response.ok((Object) fileInputStream);
    try …
Run Code Online (Sandbox Code Playgroud)

java file delete-file

2
推荐指数
1
解决办法
4923
查看次数

标签 统计

java ×3

delete-file ×1

file ×1

html ×1

javascript ×1

jquery ×1

jsp ×1

nullpointerexception ×1