我试图理解以下代码。第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) 我对 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)
当我单击帮助按钮时,它会重定向到一个空白页面。
请帮我 !
这是我删除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)