首页加载的时候跳到action里面处理
如果返回success就跳到index.jsp页面
结果在浏览器上报错:
HTTP Status 404 - No result defined for action com.xxxx.xxxx.action.IndexAction and result SUCCESS这是我的代码:
action代码:
public String execute(){
posterList = posterBIZ.getPoster();
return "SUCCESS";
}
struts.xml代码:
<action name = "index" class = "com.xxxx.xxxx.action.IndexAction" method="execute">
<result name = "SUCCESS">/index.jsp</result>
</action>
posterList是可以得到数据的
如果返回success就跳到index.jsp页面
结果在浏览器上报错:
HTTP Status 404 - No result defined for action com.xxxx.xxxx.action.IndexAction and result SUCCESS这是我的代码:
action代码:
public String execute(){
posterList = posterBIZ.getPoster();
return "SUCCESS";
}
struts.xml代码:
<action name = "index" class = "com.xxxx.xxxx.action.IndexAction" method="execute">
<result name = "SUCCESS">/index.jsp</result>
</action>
posterList是可以得到数据的
解决方案 »
- sql转hql请教,小妹不胜感激
- spring+Jpa整合问题:经测试,jpa能连上数据库,但整合spring的时候,报错,请帮忙看看,谢谢。
- 怎样利用java在页面实现树形结构图
- 求教:一个天气脚本遇到兼容性问题
- getSession()和getSessiongetServletContext()
- 关于web service传ArrayList
- 打算学习Structs,请问需要什么其他基础知识?谢谢!
- Struts的困惑?
- js怎么验证身份证号
- hibernate ONE_TO-MANY问题!想求一个语句,在查出Book表中的数据的同时查出Customer表中的数据怎么写!请高手进来看一下!!!
- 给点JAVA学习经验
- <form>提交
这里 success换成小写的
and "SUCCESS"
要么是action配置有问题
要么就是配置返回值有问题(可能就是SUCCESS的问题吧,改成小写试试!)
xml配置中result name ="success"
正解
楼主可以看看SUCESS的定义
struts.xml文件也没有错误
/去掉试试
把index改成其他也是一样
action代码:
public String execute(){
posterList = posterBIZ.getPoster();
return "SUCCESS";
}
action一般这么写
public class className extends Action{
public ActionForward execute(ActionMapping actionMapping,
ActionForm actionForm, HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) throws Exception{
看楼主给的定义这么简单不知道是故意简写的,还是没写对。
改成
<forward name="SUCCESS" path="/index.jsp" />
index.jsp路径问题吧。。
public String execute(){
posterList = posterBIZ.getPoster();
return "success";
}
struts.xml代码:
<action name = "index" class = "com.xxxx.xxxx.action.IndexAction">
<result>/index.jsp</result>
</action>
public String execute(){
posterList = posterBIZ.getPoster();
return "SUCCESS";
}
别人配的是字符串啊,又不是 return SUCCESS;
可能是这代码错了,要不就是posterList 没有提供set,get方法,要不就是posterBIZ.getPoster()里面没有值,耐心点,调试调试吧,不要因为一点小错误就问人,不然很难成长的
<result name = "SUCCESS">/index.jsp</result>
</action>
results中的success必须小写,你的后台代码中:return SUCCESS;也可以写成:return “success”;
同时method="execute"不用写,默认就是它。
return "SUCCESS";
改成
return SUCCESS;
SUCCESS是Strtus2里面定义的一个全局变量,专门用来返回后台的get set方法