Struts2 Spring2.5x ibatis2.3.4整合 404错误
web.xml加载struts<filter><filter-name>struts2filter</filter-name><filter-class>org.apac...
web.xml 加载struts
<filter>
<filter-name>struts2filter</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
struts.xml
<struts>
<package name="Struts2" extends="struts-defualt">
<action name="book" class="bookAction" method="preListBooks">
<result name="suc">/book.jsp</result>
</action>
</package>
</struts>
BookAciton.java
public String preListBooks() {
@SuppressWarnings("unused")
int currPage = 1;
if (this.pageNum > 0) {
currPage = pageNum;
}
PageResult result = bookService.listBooks(null, 100, Integer
.parseInt(super.getRequest().getParameter("pageNum")));
if (result.getResultList().size() > 0) {
super.getRequest().setAttribute("pageBean", result);
}
return "suc";
}
index.jsp调用action
<body>
<%
response.sendRedirect("book.action?pageNum=1");
%>
</body>
错误信息
HTTP Status 404 - There is no Action mapped for namespace / and action name book. 展开
<filter>
<filter-name>struts2filter</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
struts.xml
<struts>
<package name="Struts2" extends="struts-defualt">
<action name="book" class="bookAction" method="preListBooks">
<result name="suc">/book.jsp</result>
</action>
</package>
</struts>
BookAciton.java
public String preListBooks() {
@SuppressWarnings("unused")
int currPage = 1;
if (this.pageNum > 0) {
currPage = pageNum;
}
PageResult result = bookService.listBooks(null, 100, Integer
.parseInt(super.getRequest().getParameter("pageNum")));
if (result.getResultList().size() > 0) {
super.getRequest().setAttribute("pageBean", result);
}
return "suc";
}
index.jsp调用action
<body>
<%
response.sendRedirect("book.action?pageNum=1");
%>
</body>
错误信息
HTTP Status 404 - There is no Action mapped for namespace / and action name book. 展开
3个回答
展开全部
action name="book" class="bookAction" method="preListBooks"这个class里面的位置是对的么 前面还有包名没
追问
class是指定的spring的id 是spring管理的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
在struts.xml 加入 namespace="/"
追问
一样的错误
追答
是不是ibatis 的问题。ibatis中也有一个namespace 的东西。你看看,配置了是不是true.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询