用的是MultiActionController,访问http://localhost:8080/WBReport/welcomeController.do?action=showList地址报错
错误如下:
[2010-09-28 23:50:12] - org.springframework.web.servlet.PageNotFound -2714414 [h
ttp-8080-5] WARN org.springframework.web.servlet.PageNotFound - No request han
dling method with name 'showList' in class [com.wolfbase.test.WelcomeController]
以前写的代码可以运行,从网上copy如下的例子也不能运行,晕死;后来终于找到问题的原因:
ModelAndView :org.springframework.web.portlet.ModelAndView;
应该是来自:org.springframework.web.servlet.ModelAndView; 费了1个多小时呀!
package com.wolfbase.test;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.portlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
public class WelcomeController extends MultiActionController {
private String successView;
public void show(HttpServletRequest req,
HttpServletResponse resp) {
System.out.println("show-WelcomeController");
}
public ModelAndView showList(HttpServletRequest req,
HttpServletResponse resp) {
Map model = new HashMap();
model.put("success", "成功");
return new ModelAndView(this.getSuccessView(), model);
}
public ModelAndView addUser(HttpServletRequest req,
HttpServletResponse resp) {
Map model = new HashMap();
model.put("success", "增加用户成功");
return new ModelAndView(this.getSuccessView(), model);
}
public String getSuccessView() {
return successView;
}
public void setSuccessView(String successView) {
this.successView = successView;
}
}
posted on 2010-09-28 23:54
狼军团长java 阅读(843)
评论(0) 编辑 收藏