我无法在下面的课程中摆脱这个 NullPointerException 。我的控制器正在扩展这个类,当我注释掉下面的构造函数时问题就消失了......我做错了什么?
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contentController' defined in file [C:\Users\bkuhl\JavaProjects\cmt\cmt\target\cmt\WEB-INF\classes\com\site\cmt\web\ContentController.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.fettergroup.cmt.web.ContentController]: Constructor threw exception; nested exception is java.lang.NullPointerException
public class Controller {
private List<String> cssFiles;
private List<String> jsFiles;
public Controller () {
this.addCss("global.css");
this.addJs("global.js");
}
public ModelAndView render (ModelAndView model) {
//add Js & Css files
model.addObject("cssFiles", this.cssFiles);
model.addObject("jsFiles", this.jsFiles);
return model;
}
/*
* Add a css file to the page
*/
public final void addCss (String cssPath) {
cssFiles.add(this.cssFiles.size(), cssPath);
}
/*
* Add a javascript file to the page
*/
public final void addJs (String jsPath) {
jsFiles.add(this.jsFiles.size(), jsPath);
}
}