使用JavaWeb框架时直接访问Action的时候发生报错:
页面显示:
后台报错:
Action代码:
@Controller
@Scope("prototype")
@ParentPackage("struts-default")
@Namespace("/riskConfig")
public class RiskConfigAction extends BaseAction implements ModelDriven<Map> {
private RiskConfigService riskConfigService;
Map map = new HashMap();
@Override
public Map getModel() {
return map;
}
@Action(value = "getRegionList", results = {
@Result(name = "success", location = "/jsp/riskConfig/region.jsp", type = "dispatcher") })
public String getRegionList() {
List<Map<String, Object>> regionList = riskConfigService.getRegion();
request.setAttribute("regionList", regionList);
return "success";
}
}
struts.xml配置文件内容:
基本上还是Struts的配置文件的问题,修改后的配置文件如下:
修改了两行配置代码,基本上解决了当前问题,以及访问service自动注入失败导致的访问Action报空指针异常的问题
没有找到你的userService,看看你命名空间是否正确的,还有UserServiceImpl的注解写正确没有
北瓜网www.beiguaw.com