我正在开发一个spring MVC应用程序.当我尝试在我的控制器类中使用AnnotationConfigApplicationContext时,我收到以下错误.我不知道这个陈述究竟意味着什么.
@RequestMapping(value = "/generate", method = RequestMethod.POST)
public ModelAndView generateMappingFile(@ModelAttribute Mapping mapping)
{
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
MappingFileGenerator mfg = ctx.getBean(MappingFileGenerator.class);
}
Run Code Online (Sandbox Code Playgroud)
错误消息 - >
java.lang.IllegalStateException:org.springframework.context.annotation.AnnotationConfigApplicationContext@116b3c0 has not been refreshed yet
Run Code Online (Sandbox Code Playgroud)
有人能解释我这里出了什么问题吗?我正在使用Spring 4.0.1 ..我是spring mvc的新手.
我在接受采访时问了这个问题.我在这里厌倦了谷歌搜索.
我有100个方法的接口.我不想在一个类中实现所有这100个方法.有没有办法通过使用多个类而不重复实现来实现这100个方法?
例如:A类实现前10个方法(仅限).B类实现接下来的10个方法(仅),依此类推.
注意:1.实现接口的所有类必须具体.
至于我对java的了解,这是不可能的.当他问我这个问题时,他提到了适配器.这让我觉得有办法做到这一点.
任何人都可以澄清一下吗?
我正在尝试创建一个java application搜索所选doc, docx文件中的特定单词并生成报告的文件.该报告将包含搜索单词的页码和行号.现在我所取得的成就是我能够逐段阅读doc和docx文件.但我没有找到任何方法来搜索特定的单词并获得该单词所在的行和页码.我搜索了很多,但直到现在都没有运气.希望有人知道这样做的方法.
这是我的代码
if(fc.getSelectedFile().getAbsolutePath().contains("docx")) {
File file = fc.getSelectedFile();
FileInputStream fis = new FileInputStream(file.getAbsolutePath());
XWPFDocument document = new XWPFDocument(fis);
List<XWPFParagraph> paragraphs = document.getParagraphs();
System.out.println("Total no of paragraph "+paragraphs.size());
for (XWPFParagraph para : paragraphs) {
System.out.println(para.getText());
}
fis.close();
} else {
WordExtractor extractor = null;
FileInputStream fis = new FileInputStream(fc.getSelectedFile());
HWPFDocument document = new HWPFDocument(fis);
extractor = new WordExtractor(document);
String[] fileData = extractor.getParagraphText();
for …Run Code Online (Sandbox Code Playgroud) 同步适用于以下代码.
public class Main implements Runnable {
public static void main(String[] args) {
Main m = new Main();
for (int i = 0; i < 2; i++) {
Thread t = new Thread(m);
t.start();
}
}
@Override
public void run() {
synchronized(this) {
for (int i = 0; i < 500; i++) {
System.out.println(i);
}
}
}
}
// Synchronization isn't working here.
public class Main implements Runnable {
public static void main(String[] args) {
for (int i = 0; …Run Code Online (Sandbox Code Playgroud)