
NullPointerException设置属性时?
例如,我有一个将属性设置为HttpServletRequest的Servlet代码:request.setAttribute("someValue", someValue()); RequestDispatcher rd = getServletContext().getRequestDispatcher("/SomeJsp.jsp"); rd.forward(this.request, this.response); return;如何确保上面的代码是线程安全的?...
2024-01-10
什么时候可以捕获NullPointerException?
有效的Java建议我们不要这样做catch NullPointerException。总是对的吗?在许多情况下,NullPointerException仅捕获身体printStackTrace()。如果我不NullPointerException接听电话printStackTrace(),如何检查exception发生的地点?而且,如果我抓住NullPointerException了但catch身体空了,那我们那时就无法获得任何堆栈信息,可以吗...
2024-01-10
验证失败时的Nullpointerexception使用转换器的JSF
我使用的是OmniFaces的omnifaces.SelectItemsConverter,因此我可以在selectOneMenu中显示对象的字符串值。一切正常,直到验证失败(f:validateDoubleRange)。一旦验证失败,我无所谓,我在selectOneMenu中显示的对象的等号方法中获得NullPointerException。验证失败时的Nullpointerexception使用转换器的JSF这是equals方法:@Override ...
2024-01-10
Eclipse在Maven更新期间抛出NullPointerException
我一直在解决内部Eclipse错误两天。我正在运行Eclipse的最新Spring ToolSuite版本,并且试图导入现有Maven项目的集合。每当执行此操作时,Eclipse都会引发NullPointerException,但“错误日志”视图中没有可用的堆栈跟踪。如果我指示Eclipse更新Maven项目(“Maven”>“更新项目”),则会再次获得NullPointerException。...
2024-01-10
什么是NullPointerException,我该如何解决?
什么是空指针异常(java.lang.NullPointerException),什么原因导致它们?可以使用哪些方法/工具确定原因,以阻止异常导致程序过早终止?回答:声明引用变量(即对象)时,实际上是在创建指向对象的指针。考虑以下代码,在其中声明基本类型的变量int:int x;x = 10;在此示例中,变量x是an int,Java会0...
2024-01-10
Java创建对象数组时出现NullPointerException
我一直试图创建一个包含两个值的类的数组,但是当我尝试将值应用于该数组时,我得到了NullPointerException。public class ResultList { public String name; public Object value;}public class Test { public static void main(String[] args){ ResultList[] boll = new ResultList[5]; boll[0...
2024-01-10
尝试运行.jar文件时出现NullPointerException
我刚刚开始学习Java,并且只知道少量的代码,但是,这仍然是一个简单的程序。它更多是一个恶作剧程序,但主要只是为了测试我是否可以创建一个jar文件。这是代码:import java.awt.*; import java.awt.event.*; import java.lang.*; import java.util.Random; public class randommouse { public static void main(String[] args) { ...
2024-01-10
java.io.NotSerializableException
我有这个异常,我不明白为什么会抛出该异常,或者应该如何处理。try { os.writeObject(element);} catch (IOException e) { e.printStackTrace();}哪里element是一个TransformGroup包含一些其他TransformGroups类的Atom的一个实例:public class Atom extends Group implements Serializable{ float pozX,pozY; Grou...
2024-01-10
Autowired Environment is null
我在将环境连接到Spring项目时遇到问题。在这个班上@Configuration@ComponentScan(basePackages = "my.pack.offer.*")@PropertySource("classpath:OfferService.properties")public class PropertiesUtil { @Autowired private Environment environment; @Bean public String load(Stri...
2024-01-10
if语句检查是否为null,但仍然抛出NullPointerException
在此代码中。public class Test { public static void testFun(String str) { if (str == null | str.length() == 0) { System.out.println("String is empty"); } else { System.out.println("String is not empty"); } ...
2024-01-10
导出macosx的.product导致NullPointerException
我正在尝试为多个系统(linux gtk/x86,macosx cocoa/x86_64,win32 win32/x86)构建一个使用Eclipse RCP的产品,但我一直在获取NullPointerException当专门导出到macosx时。我正在运行Linux,并且linux和win32构建出口正常,没有问题。导出macosx的.product导致NullPointerException我正在运行Eclipse 3.6.2(Helios)并已安装项目的所有必...
2024-01-10
PowerMockito.doReturn返回null
这是我的课程正在测试:public class A {public Integer callMethod(){ return someMethod();}private Integer someMethod(){ //Some Code HttpPost httpPost = new HttpPost(oAuthMessage.URL); //Some Code HttpClient httpClient = new DefaultHttpClient(); HttpResponse httpR...
2024-01-10
使用for-each循环时LinkedList中的Nullpointer异常
我遇到了非常奇怪的Java行为,但我不知道这是一个bug,还是我错过了一些东西。该代码只需遍历stateStack(LinkedList)列表并销毁所有状态。public void clearStates(){ LogFactory.getLog(StateController.class.getName()) .info( "Clearing states. #ofstates="+stateStack.size()); for (State state : stateStack) ...
2024-01-10
使用CustomAdapter的ListView的NullPointerException
包含CustomAdapter文件...使用CustomAdapter的ListView的NullPointerException1.Initializing ArrayList。2.初始化ListView。从URL 3.Grapping数据和在ArrayList的4.设置的ListView与CustomAdapter存储5,请检查CustomAdapter代码在MainActivity下面..public class Screen2 extends AppCompatActivity { Progres...
2024-01-10
为什么HttpContext.Current为null?
我有在所有应用程序中使用的值;我在application_start中设置 void Application_Start(object sender, EventArgs e) { Dictionary<int, IList<string>> Panels = new Dictionary<int, IList<string>>(); List<clsPanelSetting> setting = clsPanelSettingFactory.GetAll(); foreach (cl...
2024-01-10
socket.io xhr-polling断开事件
我有一个socket.io节点脚本,其中:socket.on('disconnect', function(data) { console.log('disconnect!');});当我连接Chrome / Safari并关闭页面时,看到“断开连接!” 在我的服务器控制台中。但是,当我连接iPhone并关闭页面时,看不到此消息。我懂了debug - xhr-polling closed due to exceededduration如何通过iOS接收断开连接...
2024-01-10
Autowired属性为null-Spring Boot配置
我在自动装配的属性中陷入空值。我希望可以得到一些帮助。我们正在使用项目Spring-boot版本0.5.0.M6。带有bean的四个配置文件在一个软件包中,并按“区域”排序:数据源配置全局方法安全性配置(因为我们使用Spring-ACL)MVC配置Spring Security配置引导所有内容的主要方法在以下文件中:@EnableAspectJA...
2024-01-10
MicrosoftWebDriver加载Web驱动程序null
在Windows 10 Enterpise 64位(Microsoft Edge版本:25.10586.672.0)和MicrosoftWebDriver-版本10240的本地计算机上运行selenium时出现错误。我的Selenium版本为:3.6.0public class SeleniumTest { private WebDriver driver; @BeforeClass public void getWebDriver() { try { ...
2024-01-10
为什么等待后HttpContext.Current为null?
我有以下测试WebAPI代码,我不在生产中使用WebAPI,但由于进行了有关此问题的讨论,所以进行了此操作:WebAPI异步问题无论如何,这是令人讨厌的WebAPI方法:public async Task<string> Get(int id){ var x = HttpContext.Current; if (x == null) { // not thrown throw new ArgumentException("HttpContext.Current ...
2024-01-10
Clipboard.GetText返回null(空字符串)
我的剪贴板中填充了文本,但是当我运行时string clipboardData = Clipboard.GetText(System.Windows.Forms.TextDataFormat.Text);我得到一个空字符串。我玩弄了各种形式的电话,包括:string clipboardData = Clipboard.GetText();string clipboardData = Clipboard.GetText(System.Windows.Forms.TextDataFormat.UnicodeTe...
2024-01-10
条目中出错null值fakeoutputdirectory = null?
当我尝试运行我在Android工作室的应用程序,我得到一个错误,指出:条目中出错null值fakeoutputdirectory = null?Error null value in entry: fakeOutputDirectory = null 我试图删除文件夹.gradle,但它并不能帮助。注:我在建在AVD模拟器回答:运行从项目目录中删除.gradle文件夹,检查和更新gradle这个到匹配的版本之...
2024-01-10
Exception_Notification不知道RecordNotFound异常
我想第一次使用exception_notification。我观看了Railscast,并按照作者的指示在http://smartinez87.github.io/exception_notification/。一切似乎都适用于某种例外情况,但与其他情况无关。Exception_Notification不知道RecordNotFound异常我测试和错误,如"An ActionView::Template::Error occurred in static_pages#home:”收到的电子邮件错误notif...
2024-01-10
java.io.IOException:grpc失败
当我使用getFromLocationName调用时,我得到一个IOException,描述为“ grpc failed”。运行的代码@Overridepublic void onMapReady(GoogleMap googleMap) { mMap = googleMap; try { Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault()); List<Addre...
2024-01-10
复杂类型在ApiController参数中为null
我不知道为什么我的参数“ ParametroFiltro Filtro”为空,为什么其他参数“ page”和“ pageSize”都可以。public class ParametroFiltro{ public string Codigo { get; set; } public string Descricao { get; set; }}我的ApiController的Get方法:public PagedDataModel<ParametroDTO> Get(ParametroFiltro ...
2024-01-10
Java-拒绝访问java.io.FileNotFoundException
我有以下代码:List<FileItem> items = uploadHandler.parseRequest(request);for (FileItem item : items) { if (!item.isFormField()) { File file = new File("D:/Data"); }}当我尝试保存文件时,出现以下错误java.io.FileNotFoundException: D:\Data (Access is denied.)原因可能是什么,我该如...
2024-01-10
