struts2,找了半天,不知道错误在哪!能试的方法都试过了,实在没办法!!求指导!!!!!
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> <package name="bbs" extends="struts-default" namespace=""> <action name="*User" class="com.njit.kepeng.action.UserAction" method="{1}User"> <result>/chooseModel.jsp</result> <result name="input">/login.jsp</result> <result name="manager">/manager.jsp</result> <result name="list" type="redirectAction"> <param name="namespace">/</param> <param name="actionName">list</param> /user_list.jsp </result> </action> </package> </struts>
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>
package com.njit.kepeng.action; import java.util.List; import com.njit.kepeng.entity.User; import com.njit.kepeng.service.IUserService; import com.njit.kepeng.service.impl.UserService; import com.opensymphony.xwork2.ActionSupport; public class UserAction extends ActionSupport { private User user; private List<User> users; private IUserService userService = new UserService(); public String ListUser() { users = userService.selectUsers(new User()); return "list"; } public List<User> getUsers() { return users; } public void setUsers(List<User> users) { this.users = users; } public String loginUser() { User u = userService.selectUsers(user).get(0); if (u == null) { return INPUT; } else if (u.getUserRole().getRoleId() == 0) { return "manager"; } else { return SUCCESS; } } public User getUser() { return user; } public void setUser(User user) { this.user = user; } }
报错:
There is no Action mapped for namespace [/] and action name [list] associated with context path [/BBS]. - [unknown location] at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185) at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63) at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39) at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:501) at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:619)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
厉害!
厉害!很有道理!!!
你的重定向到action的actionName是"list",根本不符合你的action定义的格式为“*User”,所以匹配不了。
<
param
name
=
"actionName"
>list</
param
>