struts2.5 测试action老是404,大神救救我。。

报错ypeStatusReportMessage/juicy/LoginAction.actionDescriptionTheoriginserverdidnotfindacurrentrepresentationforthetargetresourceorisnotwillingtodisclosethatoneexists.-------------------------------------------------------------login.jsp:%@pagelanguage="java"contentType="text/html;charset=UTF-8"pageEncoding="UTF-8"%!DOCTYPEhtmlhtmlheadmetacharset="UTF-8"titleInserttitlehere/title/headbodyformaction="LoginAction.action"用户名:inputtype="text"name="username"br密码inputtype="text"name="pwd"brinputtype="submit"value="提交"/form/body/html-------------------------------------------------------------web.xml和struts.xml:?xmlversion="1.0"encoding="UTF-8"?web-appversion="2.4"xmlns=""xmlns:xsi=""xsi:schemaLocation="_2_4.xsd"display-nameStrutsApplication/display-namefilterfilter-namestruts2/filter-namefilter-classorg.apache.struts2.dispatcher.filter.StrutsPrepareFilter/filter-class/filterfilter-mappingfilter-namestruts2/filter-nameurl-pattern/*/url-pattern/filter-mappingwelcome-file-listwelcome-filelogin.jsp/welcome-file/welcome-file-list/web-app?xmlversion="1.0"encoding="UTF-8"?!DOCTYPEstrutsPUBLIC"-//ApacheSoftwareFoundation//DTDStrutsConfiguration2.5//EN"""!--STARTSNIPPET:xworkSample--struts!--Struts。xml的配备文件--!--全数匹配*.action的央浼都由struts2管理--constantname="struts.action.extension"value="action"/!--是不是启用开拓格局--constantname="struts.devMode"value="true"/!--struts配置文件改变后,是不是再度加载--constantname="struts.configuration.xml.reload"value="true"/!--乞请参数的编码格局--constantname="struts.i18n.encoding"value="utf-8"/!--每一次HTTP恳求系统都重复加载能源文件--constantname="struts.i18n.reload"value="true"/!--让struts2支撑动态方法调用--constantname="struts.enable.DynamicMethodInvocation"value="true"/!--新建二个package,name随便,extends自struts-default--packageextends="struts-default"name="default"strict-method-invocation="false"actionname="LoginAction"method="Login"resultname="success"success.jsp/resultresultname="error"error.jsp/result/action/package/struts!--ENDSNIPPET:xworkSample---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------action代码:packagestruts;importcom.opensymphony.xwork2.ActionSupport;publicclassLoginActionextendsActionSupport{//世襲ActionSupport类以直接动用SUCCESS,LOGIN等变量和重写execute等格局//申明顾客名和密码的实例变量;publicStringusername;publicintpwd;//必要在xml里调用的Login方法:publicStringLogin(卡塔尔(قطر‎{System.out.println(username+""+pwd卡塔尔(قطر‎;if(username.trim(卡塔尔国.equals("aaa"卡塔尔pwd==123卡塔尔国{return"success";}else{return"error";}}//系统生成的get和set方法publicStringgetUsername(卡塔尔(قطر‎{returnusername;}publicvoidsetUsername(Stringusername卡塔尔国{this.username=username;}publicintgetPwd(卡塔尔{returnpwd;}publicvoidsetPwd(intpwd卡塔尔(قطر‎{this.pwd=pwd;}}tomcat8.5struts.xml和web.xml目录如截图

真钱捕鱼 1

struts2映射action,一贯报错找不到action,然则配置相应没难题
请各位抽空帮三弟看下,多谢
struts2.5 测试action老是404,大神救救我。。。那是本人的web.xml文件
[code="xml"]
<?xml version="1.0" encoding="UTF-8"?>
xmlns=""
xmlns:xsi=""
xsi:schemaLocation="
;

奉公守法书上看见是说struts2是先举行拦截器,然后实践ACTION,然后再履行拦截器(与原先调用顺序相反卡塔尔。可是在骨子里操作书中实例的时候有个疑心,小编先贴书中圭表代码,各位援助看看。web.xml?xmlversion="1.0"encoding="UTF-8"?web-appxmlns:xsi=""xmlns=""xsi:schemaLocation="_3_0.xsd"version="3.0"display-nameschapter03/display-namewelcome-file-listwelcome-fileindex.html/welcome-filewelcome-fileindex.htm/welcome-filewelcome-fileindex.jsp/welcome-filewelcome-filedefault.html/welcome-filewelcome-filedefault.htm/welcome-filewelcome-filedefault.jsp/welcome-file/welcome-file-listfilterfilter-namestruts2/filter-namefilter-classorg.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter/filter-class/filterfilter-mappingfilter-namestruts2/filter-nameurl-pattern/*/url-pattern/filter-mapping/web-appUser.javapackagecn.itcast.domain;publicclassUser{privateStringusername;privateStringpassword;publicStringgetUsername(State of Qatar{returnusername;}publicvoidsetUsername(StringusernameState of Qatar{this.username=username;}publicStringgetPassword(State of Qatar{returnpassword;}publicvoidsetPassword(Stringpassword卡塔尔(قطر‎{this.password=password;}}LoginAction.javapackagecn.itcast.action;importcom.opensymphony.xwork2.ActionContext;importcom.opensymphony.xwork2.ActionSupport;importcom.opensymphony.xwork2.ModelDriven;importcn.itcast.domain.User;publicclassLoginActionextendsActionSupportimplementsModelDrivenUser{privateUseruser=newUser(卡塔尔;publicUsergetModel(卡塔尔{returnuser;}@OverridepublicStringexecute(卡塔尔国throwsException{//获取ActionContextActionContextactionContext=ActionContext.getContext(卡塔尔;if("tom".equals(user.getUsername(卡塔尔(قطر‎卡塔尔(قطر‎"123".equals(user.getPassword(卡塔尔国卡塔尔(قطر‎卡塔尔{//将客户存款和储蓄在session中actionContext.getSession(State of Qatar.put("user",userState of Qatar;returnSUCCESS;}else{actionContext.put("msg","顾客名或密码不科学"卡塔尔(قطر‎;returnINPUT;}}}BookAction.javapackagecn.itcast.action;importcom.opensymphony.xwork2.ActionSupport;publicclassBookActionextendsActionSupport{publicStringadd(State of Qatar{System.out.println("bookadd"卡塔尔;returnSUCCESS;}publicStringdel(State of Qatar{System.out.println("bookdel"卡塔尔国;returnSUCCESS;}publicStringupdate(State of Qatar{System.out.println("bookupdate"卡塔尔;returnSUCCESS;}publicStringfind(卡塔尔{System.out.println("bookfind"卡塔尔国;returnSUCCESS;}}main.jsp%@pagelanguage="java"import="java.util.*"pageEncoding="utf-8"%htmlheadtitlemain.jsp/title/headbodyahref="book_del"bookdel/aahref="book_add"bookadd/aahref="book_update"bookupdate/aahref="book_find"bookfind/a/body/htmllogin.jsp%@pagelanguage="java"import="java.util.*"pageEncoding="utf-8"%htmlheadtitle登录/title/headbodycenter${requestScope.msg}brformaction="login.action"method="post"tabletrtdlable用户名:/lable/tdtdinputtype="text"name="username"/td/trtrtdlabel密码:/label/tdtdinputtype="password"name="password"/td/trtrtdalign="right"colspan="2"inputtype="submit"value="登录"//td/tr/table/form/center/body/htmlsuccess.jsp%@pagelanguage="java"import="java.util.*"pageEncoding="utf-8"%htmlheadtitle成功页面/title/headbody客商${user.username}操作成功/body/htmlstruts.xml?xmlversion="1.0"encoding="UTF-8"?!DOCTYPEstrutsPUBLIC"-//ApacheSoftwareFoundation//DTDStrutsConfiguration2.3//EN"""strutspackagename="default"namespace="/"extends="struts-default"!--拦截器证明--interceptorsinterceptorname="privilege"/interceptorinterceptor-stackname="myStack"interceptor-refname="defaultStack"/interceptor-refinterceptor-refname="privilege"/interceptor-ref/interceptor-stack/interceptorsactionname="login"resultname="success"/main.jsp/resultresultname="input"/login.jsp/result/actionactionname="book_*真钱捕鱼 ,"method="{1}"resultname="success"/success.jsp/resultresultname="login"/login.jsp/resultinterceptor-refname="myStack"/interceptor-ref/action/package/struts实操了一回确实如上述图片书中所写,点击main主页中链接,拦截器PrivilegeInterceptor起了阻碍效用,跳转到了login.jsp页面必要顾客登陆。然则大家在login.jsp页面填写准确客商名密码后,表单提交到login.action,那时在推行login.action以前按拦截器准则来讲,应该也是先实行PrivilegeInterceptor拦截器啊,然而在实行PrivilegeInterceptor拦截器时候是因为我们还没施行login.action,大家还未把表单提交的username和password封装到user类中,由此也尚未施行到loginacion中actionContext.getSession(卡塔尔国.put("user",userState of Qatar;所以意味着名称为"user"的session还没更改,那大家在实行PrivilegeInterceptor拦截器的时候不就非常的小概得到"user"session的值,在认清的时候不是应当user=null,又陷入登陆验证的巡回。可是实操是在该环节,通过了拦截器。由此在此处想不通,为何"user"session会在推行拦截器在此以前就封装进去了吧?

index.jsp

struts2
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

struts2
/*

[/code]

这是struts.xml文件
[code="xml"]
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
";

<!--

返回列表