SSH架构遇到Http struts500问题,一直解决不了!!!!!!
控制台没有报错,网页报错:
HTTP Status 500 - Index: 0, Size: 0
type Exception report
message Index: 0, Size: 0
description The server encountered an internal error that prevented it from fulfilling this request.
exception
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
java.util.ArrayList.RangeCheck(ArrayList.java:547)
java.util.ArrayList.get(ArrayList.java:322)
impl.WpcountryService.find(WpcountryService.java:27)
struts.action.PersonInfoAction.addpersonInfo(PersonInfoAction.java:32)
struts.action.PersonInfoAction.personInfo(PersonInfoAction.java:24)
其中impl.WpcountryService.find(WpcountryService.java:27)这里是这样写的:
public WpCountry find(String coun_id){
ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml");
wpCountryDAO=(WpCountryDAO)context.getBean("WpCountryDAO");
List<WpCountry> wc = new ArrayList<WpCountry>();
wc = wpCountryDAO.findByCounName(coun_id);
WpCountry w = new WpCountry();
w = wc.get(0);
return w;
}
其中:struts.action.PersonInfoAction.addpersonInfo(PersonInfoAction.java:32)是这样的:
public boolean addpersonInfo(){
boolean s = wpuserService.addinfo(email, name, sex, personid,
wpcountryService.find(country));
return s;
}
其中struts.action.PersonInfoAction.personInfo(PersonInfoAction.java:24)是这样的:
public String personInfo(){
if(
addpersonInfo()){
return "yes";
}else{
return "no";
}
}
希望前辈可以帮我解决解决一下!这样是报错的,但是我这样写就不会报错:
public static void main(String[] args) {
WpcountryService wps =new WpcountryService();
WpuserService as = new WpuserService();
as.
addinfo("ok", "dsa", "F", "assadsadsa",
wps.find("中国"));
}
在工程里新建一个main函数,这样写是插入成功的!!!
我就搞不懂了……帮我一下吧