eclipse struts2 action访问总是404 20C

最近开始学习struts2,建了个简单练习,然而,action控制器总是404,弄了好久了
,直接访问webcontent下的jsp文件是可以的,但是这个action总是有毒!!求大神
刚刚发了一次悬赏,但是不知道怎么的,根本看不到代码,逼我再发一次。

index.jsp

 <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>helloword</title>
</head>
<body>
sdfasdfasdfasdfa
  <a href="${pageContext.request.contextPath }/helloworld.action">6666666</a>

</body>
</html>

web.xml

 <web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <display-name>Struts Blank</display-name>

    <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.html</welcome-file>
    </welcome-file-list>

    <!-- Restricts access to pure JSP files - access available only via Struts action -->
    <security-constraint>
        <display-name>No direct JSP access</display-name>
        <web-resource-collection>
            <web-resource-name>No-JSP</web-resource-name>
            <url-pattern>*.jsp</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>no-users</role-name>
        </auth-constraint>
    </security-constraint>

    <security-role>
        <description>Don't assign users to this role</description>
        <role-name>no-users</role-name>
    </security-role>

</web-app>

struts.xml

 <struts>
  <!-- Struts2的Action必须放在指定的包空间下定义 -->
  <package name="hello" extends="struts-default" namespace="/*">
    <!-- 定义 action,该action对应的类为cn.itcast.action.HelloWorldAction类 
    -->  
    <action name="helloworld" class="cn.itcast.action.HelloWorldAction">
      <!-- 定义处理结果和视图资源之间的映射关系 -->
     <result name="success">/success.jsp</result>
    </action>
  </package>
</struts>

HelloWorldAction.java

 package cn.itcast.action;

import com.opensymphony.xwork2.ActionSupport;

public class HelloWorldAction extends ActionSupport{
    public String execute() throws Exception{
        System.out.println("dddddd");
        int i=0;
        return "success";
    }
}

最后加个目录结构
图片说明

8个回答

 <web-resource-collection>
            <web-resource-name>No-JSP</web-resource-name>
            <url-pattern>/*.jsp</url-pattern>
        </web-resource-collection>
qq_39846275
帅气的张张 不知怎么的,我现在都打不开了,连JSP直接访问都不行了,
2 年多之前 回复

Struts.xml 里面action没有指定class?指定class到对应action才能找到对应的。

你先单独打开一个浏览器标签页输入路径进行访问看看是不是还是报错404,如果还是报错404,那么可能是路径有问题。重新改一下路径。
你试试把web.xml中的路径由/*变成 *.action试试看。
在你要进入的方法里面打个断点。或者检查你的指向类或者result标签处理之后返回的页面。返回值看看是不是和你方法返回值一样。

SetMyLife
千劫 再有就是你的struts2的配置文件...看看你是不是放在src目录
2 年多之前 回复

web.xml里面:试试

No-JSP
/*.jsp

package name="hello" extends="struts-default" namespace="/*" 中的namespace="/*" 改为namespace="/ ”

starts配置文件中路径..

检查struts是否在src目录下

报404错误应该是你哪里的路径配置出问题了,你看看struts.xml中路径是否配置正确

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
eclipse struts2 action访问总是404

最近开始学习struts2,建了个练习的项目,然而出手就卡死,index.jsp和success.jsp都可以直接访问, 但是问什么访问helloworld.action就404,跳转直接访问都不行,新手,求大神,妈的我传了6个图,为什么只有1张,我擦,我用手机根本看不到图, ![![![![![![图片说明](https://img-ask.csdn.net/upload/201712/26/1514277761_956707.png) ![图片说明](https://img-ask.csdn.net/upload/201712/26/1514277965_79534.png) ![图片说明](https://img-ask.csdn.net/upload/201712/26/1514277980_376560.png) ![图片说明](https://img-ask.csdn.net/upload/201712/26/1514277991_779350.png) ![图片说明](https://img-ask.csdn.net/upload/201712/26/1514278003_407192.png) ![图片说明](https://img-ask.csdn.net/upload/201712/26/1514278014_328380.png) 由于看不到图,我再贴一次 index.jsp ``` <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>helloword</title> </head> <body> sdfasdfasdfasdfa <a href="${pageContext.request.contextPath }/helloworld.action">6666666</a> </body> </html> ``` web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>Struts Blank</display-name> <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.html</welcome-file> </welcome-file-list> <!-- Restricts access to pure JSP files - access available only via Struts action --> <security-constraint> <display-name>No direct JSP access</display-name> <web-resource-collection> <web-resource-name>No-JSP</web-resource-name> <url-pattern>*.jsp</url-pattern> </web-resource-collection> <auth-constraint> <role-name>no-users</role-name> </auth-constraint> </security-constraint> <security-role> <description>Don't assign users to this role</description> <role-name>no-users</role-name> </security-role> </web-app> struts.xml ``` <?xml version="1.0" encoding="UTF-8"?> <!-- 指定Struts2配置文件的DTD信息 --> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <!-- Struts2配置文件的根元素 --> <struts> <!-- Struts2的Action必须放在指定的包空间下定义 --> <package name="hello" extends="struts-default" namespace="/"> <!-- 定义 action,该action对应的类为cn.itcast.action.HelloWorldAction类 --> <action name="helloworld" class="cn.itcast.action.HelloWorldAction"> <!-- 定义处理结果和视图资源之间的映射关系 --> <result name="success">/success.jsp</result> </action> </package> </struts> ``` HelloWorldAction.java ``` package cn.itcast.action; import com.opensymphony.xwork2.ActionSupport; public class HelloWorldAction extends ActionSupport{ public String execute() throws Exception{ System.out.println("dddddd"); int i=0; return "success"; } } ```

运行一个Struts2程序总是出现404的错误

![图片说明](https://img-ask.csdn.net/upload/201705/04/1493907445_121308.png) ![图片说明](https://img-ask.csdn.net/upload/201705/04/1493907466_9862.png) ![图片说明](https://img-ask.csdn.net/upload/201705/04/1493907491_924782.png) ![图片说明](https://img-ask.csdn.net/upload/201705/04/1493907511_309262.png) ![图片说明](https://img-ask.csdn.net/upload/201705/04/1493907524_401264.png) 上面是我写的类以及配置文件,struts2入门,请大神指教。 运行之后 ![图片说明](https://img-ask.csdn.net/upload/201705/04/1493907665_418091.png)

struts2 找不到action 页面404

QAQ大晚上的有没有人啊啊啊啊呜呜呜 struts.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <package name="DoudouShop" extends="struts-default"> <action name="login" class="doudou.struts.aciton.AdminAction"> <result name="success">/loginsuccess.jsp</result> <result name="error">/loginerror.jsp</result> </action> </package> </struts> web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:web="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <display-name>DoudouShop</display-name> <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> </web-app> AdminAction.java package doudou.struts.action; import com.opensymphony.xwork2.ActionSupport; import doudou.service.AdminServiceImpl; public class AdminAction extends ActionSupport { private String adminType; private String loginPwd; private String loginName; private String adminName; public String getAdminType() { return adminType; } public void setAdminType(String adminType) { this.adminType = adminType; } public String getLoginPwd() { return loginPwd; } public void setLoginPwd(String loginPwd) { this.loginPwd = loginPwd; } public String getLoginName() { return loginName; } public void setLoginName(String loginName) { this.loginName = loginName; } public String getAdminName() { return adminName; } public void setAdminName(String adminName) { this.adminName = adminName; } public String adminLogin() throws Exception{ AdminServiceImpl b=new AdminServiceImpl(); if(b.adminLogin(loginName, loginPwd)==null) return"success"; else return"error"; } } 我运行最基本的jsp(没加任何内容) 还是显示404啊为什么啊 六月 12, 2016 12:55:27 上午 org.apache.catalina.core.StandardContext startInternal 严重: One or more Filters failed to start. Full details will be found in the appropriate container log file 六月 12, 2016 12:55:27 上午 org.apache.catalina.core.StandardContext startInternal 严重: Context [/DoudouMall] startup failed due to previous errors 六月 12, 2016 12:55:28 上午 org.apache.catalina.startup.TldConfig execute 信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. log4j:WARN No appenders could be found for logger (com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. 六月 12, 2016 12:55:29 上午 org.apache.catalina.core.StandardContext filterStart 严重: Exception starting filter struts2 Unable to load configuration. - action - file:/D:/JEEworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/DoudouShop/WEB-INF/classes/struts.xml:7:71 at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:501) at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57) at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4908) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5602) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1572) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1562) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: Unable to load configuration. - action - file:/D:/JEEworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/DoudouShop/WEB-INF/classes/struts.xml:7:71 at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:445) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:489) ... 14 more Caused by: Action class [doudou.struts.aciton.AdminAction] not found - action - file:/D:/JEEworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/DoudouShop/WEB-INF/classes/struts.xml:7:71 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:482) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:426) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:552) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:292) at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112) at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:258) at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67) ... 16 more 六月 12, 2016 12:55:29 上午 org.apache.catalina.core.StandardContext startInternal 严重: One or more Filters failed to start. Full details will be found in the appropriate container log file 六月 12, 2016 12:55:29 上午 org.apache.catalina.core.StandardContext startInternal 严重: Context [/DoudouShop] startup failed due to previous errors 六月 12, 2016 12:55:29 上午 org.apache.coyote.AbstractProtocol start 信息: Starting ProtocolHandler ["http-bio-8080"] 六月 12, 2016 12:55:29 上午 org.apache.coyote.AbstractProtocol start 信息: Starting ProtocolHandler ["ajp-bio-8009"] 六月 12, 2016 12:55:29 上午 org.apache.catalina.startup.Catalina start 信息: Server startup in 12908 ms

spring与struts2整合之后,404错误,控制台不报错

web.xml中 ![图片说明](https://img-ask.csdn.net/upload/201801/08/1515417894_937978.png) struts.xml中 ![图片说明](https://img-ask.csdn.net/upload/201801/08/1515417920_314085.png) bean中 ![图片说明](https://img-ask.csdn.net/upload/201801/08/1515417942_333412.png) action中 ![图片说明](https://img-ask.csdn.net/upload/201801/08/1515417966_582335.png) jar包 ![图片说明](https://img-ask.csdn.net/upload/201801/08/1515417982_530783.png) 目前的问题是连WEB-INF中的index.jsp都进不去提示404错误,并且控制台不报错。很诡异的是将web.xml删除了之后就可以打开index.jsp页面

怎么用eclipse查看struts2源码!

如题,试了好几遍都说加载失败 :twisted: 我在java build path中应经指定了struts2-core-2.1.8.1jar的source attachment的zip文件,xwork-core-2.1.6也指定了zip文件,可就是看不到源码。。。 谁弄过,指点一下 waiting on line。。。。

struts2 action配置问题

添加一条数据点击保存后,怎么才能跳到遍历的页面,并把新添加的也遍历出来,XML文件中的action如何配置![图片说明](http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/9.gif)一直提示Null。。

struts2在web.xml中添加支持后访问所有页面报404错误,什么原因?

struts2在web.xml中添加支持后访问所有页面报404错误,本地测试无任何问题,上传服务器就报所有页面404. ![图片说明](https://img-ask.csdn.net/upload/201511/27/1448593864_493029.png) web.xml ![图片说明](https://img-ask.csdn.net/upload/201511/27/1448593964_37024.png) struts.xml ![图片说明](https://img-ask.csdn.net/upload/201511/27/1448594035_586595.png) 运行后

struts2没有调用action类自定义的方法,跳转404

一直没有调用action方法,控制台无报错信息,登陆跳转404。 web.xml: ``` <?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"> <display-name></display-name> <welcome-file-list> <welcome-file>login.jsp</welcome-file> </welcome-file-list> <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>*.action</url-pattern> </filter-mapping></web-app> ``` struts.xml: ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN" "http://struts.apache.org/dtds/struts-2.5.dtd"> <struts> <constant name="struts.action.extension" value="true" /> <package name="strut2" extends="struts-default"> <action name="Login" class="loginAction.LoginAction" method="user"> <result name="usersuccess">/user.jsp</result> <result name="adminsuccess">/admin.jsp</result> <result name="fail">/fail.jsp</result> </action> </package> </struts> ``` 试过将method改为函数名称,也试过删去<constant> aciton类: ``` package loginAction; public class LoginAction { private String account; public String getAccount(){ return account; } public void setAccount(String account){ this.account=account; } private String password; public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String user()throws Exception{ System.out.print('1'); if(account.equals(password)){ System.out.println("执行user方法"); return "usersuccess"; } return "fail"; } public String admin()throws Exception{ if(account.equals(password)){ System.out.println("执行admin方法"); return "adminsuccess"; } return "fail"; } } ``` 试过删去set,get方法不行,函数没有调用(控制台无1输出) login.jsp ``` <%@ page contentType="text/html;charset=UTF-8" language="java" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <body> 普通用户登录: <form action = "login-user" method="post"> 请您输入账号:<input name="account" type="text"><br> 请您输入密码:<input name="password" type="password"> <input type="submit" value="登录"> </form><br> 管理员用户登录: <form action = "login-admin" method="post"> 请您输入账号:<input name="account" type="text"><br> 请您输入密码:<input name="password" type="password"> <input type="submit" value="登录"> </form> </body> </html> ``` 试过将action 改为/形式 其他三个登陆成功(失败)页面相似: ``` <%@ page contentType="text/html;charset=UTF-8" language="java" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <body> 普通用户登陆成功。 </body> </html> ``` 确认struts2包齐全,由myeclipse内部struts2.2.1,struts.xml也在tomcat中的class文件夹中生成

eclipse中创建一个struts项目如下,运行报错(HTTP Status 404 - /struts2-003/TestActionContext.Action)

![![图片说明](https://img-ask.csdn.net/upload/201606/27/1467017955_643184.png)图片说明](https://img-ask.csdn.net/upload/201606/27/1467017933_533168.png) ![图片说明](https://img-ask.csdn.net/upload/201606/27/1467017978_301877.png) ![图片说明](https://img-ask.csdn.net/upload/201606/27/1467017999_601237.png) ![图片说明](https://img-ask.csdn.net/upload/201606/27/1467018029_310187.png)![图片说明](https://img-ask.csdn.net/upload/201606/27/1467018084_118377.png)![图片说明](https://img-ask.csdn.net/upload/201606/27/1467018076_798136.png)

struts2总是找不到action问题

![![![图片说明](https://img-ask.csdn.net/upload/201708/01/1501592406_677558.png)图片说明](https://img-ask.csdn.net/upload![图片说明](https://img-ask.csdn.net/upload/201708/01/1501592414_906115.png)/201708/01/1501592396_94777.png)图片说明](https://img-ask.csdn.net/upload/201708/01/1501592388_275492.png)

myeclipse上面写一个简单的struts2项目action完成跳转

![图片说明](https://img-ask.csdn.net/upload/201802/26/1519650119_259293.png) ![图片说明](https://img-ask.csdn.net/upload/201802/26/1519650128_385777.png) ![图片说明](https://img-ask.csdn.net/upload/201802/26/1519650138_285982.png) ![图片说明](https://img-ask.csdn.net/upload/201802/26/1519650147_563213.png) ![图片说明](https://img-ask.csdn.net/upload/201802/26/1519650156_886021.png) myeclipse 上面写一个简单的struts2项目 就是完成一个ation的调整就是一个劲报错 求大神指点一二 严重: Dispatcher initialization failed Unable to load configuration. - action - file:/D:/apache-tomcat-8.5.23/webapps/wwww/WEB-INF/classes/struts.xml:6:59 at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:69) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:371) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415) at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51) at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:285) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:266) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4591) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5233) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1144) at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1878) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: Action class [cn.itcast.action.HelloAction] not found - action - file:/D:/apache-tomcat-8.5.23/webapps/wwww/WEB-INF/classes/struts.xml:6:59 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:420) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:365) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:479) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:275) at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111) at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:204) at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66) ... 20 more 二月 26, 2018 8:59:05 下午 org.apache.catalina.core.StandardContext filterStart 严重: Exception starting filter [struts2] Unable to load configuration. - action - file:/D:/apache-tomcat-8.5.23/webapps/wwww/WEB-INF/classes/struts.xml:6:59 at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:428) at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51) at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:285) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:266) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4591) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5233) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1144) at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1878) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: Unable to load configuration. - action - file:/D:/apache-tomcat-8.5.23/webapps/wwww/WEB-INF/classes/struts.xml:6:59 at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:69) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:371) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415) ... 18 more Caused by: Action class [cn.itcast.action.HelloAction] not found - action - file:/D:/apache-tomcat-8.5.23/webapps/wwww/WEB-INF/classes/struts.xml:6:59 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:420) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:365) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:479) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:275) at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111) at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:204) at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66) ... 20 more 非常恐惧 试了很多遍 查了很多网上 的 找不到错误在哪里

action在Struts2中配置了,但是点击超链接的时候没有跳转到指定页面

# action类 package zww.com.domain; import java.util.Map; import com.opensymphony.xwork2.ActionContext; public class TestActionContextAction { public String execute(){ System.out.println("success"); return "success"; } } # struts.xml的配置 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN" "http://struts.apache.org/dtds/struts-2.5.dtd"> <struts> <package name="default" namespace="/" extends="struts-default"> <action name="TestContextAction" class="zww.com.domain.TestActionContextAction" method="execute"> <result name="success">/test-ContextAction.jsp</result> </action> </package> <!-- 请求参数的编码方式 --> <constant name="struts.i18n.encoding" value="UTF-8" /> <!-- 指定被struts2处理的请求后缀类型。多个用逗号隔开 --> <constant name="struts.action.extension" value="action,do,go,qqi" /> <!-- 当struts.xml改动后,是否重新加载。默认值为false(生产环境下使用),开发阶段最好打开 --> <constant name="struts.configuration.xml.reload" value="true" /> <!-- 是否使用struts的开发模式。开发模式会有更多的调试信息。默认值为false(生产环境下使用),开发阶段最好打开 --> <constant name="struts.devMode" value="false" /> <!-- 设置浏览器是否缓存静态内容。默认值为true(生产环境下使用),开发阶段最好关闭 --> <constant name="struts.serve.static.browserCache" value="false" /> <!-- 指定由spring负责action对象的创建 <constant name="struts.objectFactory" value="spring"/> --> <!-- 是否开启动态方法调用 --> <constant name="struts.enable.DynamicMethodInvocation" value="false" /> </struts> # 点击的超链接 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <a href="TestContextAction.action?name=weiwei">testAction</a> </body> </html> # 跳转到的页面信息 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <h1>TestContextAction</h1> </body> </html>

structs2 访问action报错404

``` <package name="sysRights" extends="struts-default" namespace="/sysRights"> <action name="*User" class="com.sinatay.core.system.web.actions.UserAction" method="{1}"> <result name="main">/pages/framework/main.jsp</result> <result name="login">/pages/login/login.jsp</result> <result name="init">/pages/sysRights/userMgr.jsp</result> <result name="initForm">/pages/sysRights/userForm.jsp</result> </action> ``` <br/> 通过js方法location.href跳转地址:http://localhost:8080/WorkflowWeb/sysRights/logoutUser.action <br/> 在UserAction里添加了logout方法,但是无法映射到这个方法里面,且eclipse控制台没有报错。 <br/> http响应为:404 Not Found <br/> 但是将跳转地址后缀改为loginUser.action可以映射到login()方法,求大佬指点。 <br/> 问题更新:其实进入了logout方法,只是在跳转jsp的时候报错了。

struts2 启动项目时报错,action类无法加载到tomcat中,是什么原因?

2015-8-9 21:37:25 org.apache.tomcat.util.digester.SetPropertiesRule begin 警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Test' did not find a matching property. 2015-8-9 21:37:25 org.apache.catalina.core.AprLifecycleListener init 信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\java\JDK1.6\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Intel\DMIX;D:\java\JDK1.6\bin;D:\java\JDK1.6\jre\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;. 2015-8-9 21:37:25 org.apache.coyote.http11.Http11Protocol init 信息: Initializing Coyote HTTP/1.1 on http-8088 2015-8-9 21:37:25 org.apache.catalina.startup.Catalina load 信息: Initialization processed in 625 ms 2015-8-9 21:37:25 org.apache.catalina.core.StandardService start 信息: Starting service Catalina 2015-8-9 21:37:25 org.apache.catalina.core.StandardEngine start 信息: Starting Servlet Engine: Apache Tomcat/6.0.20 2015-8-9 21:37:26 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info 信息: Parsing configuration file [struts-default.xml] 2015-8-9 21:37:26 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info 信息: Unable to locate configuration files of the name struts-plugin.xml, skipping 2015-8-9 21:37:26 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info 信息: Parsing configuration file [struts-plugin.xml] 2015-8-9 21:37:26 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info 信息: Parsing configuration file [struts.xml] 2015-8-9 21:37:26 org.apache.coyote.http11.Http11Protocol start 信息: Starting Coyote HTTP/1.1 on http-8088 2015-8-9 21:37:26 org.apache.jk.common.ChannelSocket init 信息: JK: ajp13 listening on /0.0.0.0:8009 2015-8-9 21:37:26 org.apache.jk.server.JkMain start 信息: Jk running ID=0 time=0/32 config=null 2015-8-9 21:37:26 org.apache.catalina.startup.Catalina start 信息: Server startup in 1655 ms 2015-8-9 21:37:43 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn 警告: Could not find action or result There is no Action mapped for namespace / and action name . - [unknown location] at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:189) at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61) 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:475) 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:128) 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:849) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454) at java.lang.Thread.run(Thread.java:662)

Struts2始终报错,请各位大神讲解

刚刚开始学习Struts2,配置正确但是始终不能运行. 错误信息: Unable to load configuration. - action - file:/E:/workplace/j2eeworkplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/ActionContext/WEB-INF/classes/struts.xml:10:67 at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70) at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:967) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:435) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:479) at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57) at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4854) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5546) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: Action class [org.crazyit.app.action.LoginAction] not found - action - file:/E:/workplace/j2eeworkplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/ActionContext/WEB-INF/classes/struts.xml:10:67 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:486) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:429) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:556) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:295) at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112) at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:264) at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67) ... 17 more 七月 12, 2015 2:17:51 下午 org.apache.catalina.core.StandardContext filterStart 严重: Exception starting filter struts2 Unable to load configuration. - action - file:/E:/workplace/j2eeworkplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/ActionContext/WEB-INF/classes/struts.xml:10:67 at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:493) at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57) at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4854) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5546) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: Unable to load configuration. - action - file:/E:/workplace/j2eeworkplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/ActionContext/WEB-INF/classes/struts.xml:10:67 at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70) at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:967) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:435) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:479) ... 14 more Caused by: Action class [org.crazyit.app.action.LoginAction] not found - action - file:/E:/workplace/j2eeworkplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/ActionContext/WEB-INF/classes/struts.xml:10:67 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:486) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:429) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:556) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:295) at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112) at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:264) at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67) ... 17 more web.xml <?xml version="1.0" encoding="GBK"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> <!-- 定义Struts 2的核心Filter --> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <!-- 让Struts 2的核心Filter拦截所有请求 --> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app> struts.xml <?xml version="1.0" encoding="GBK"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> <constant name="conststruts.devMode" value="true"/> <!-- Struts2的所有Action都需位于package下 --> <package name="wxc" extends="struts-default"> <!-- 定义名为login的Action,其实现类为LoginAction类 --> <action name="login" class="org.crazyit.app.action.LoginAction"> <!-- 处理结果返回error,对应/WEB-INF/content/error.jsp视图资源 --> <result name="error">/WEB-INF/content/error.jsp</result> <!-- 处理结果返回success,对应/WEB-INF/content/welcome.jsp视图资源 --> <result>/WEB-INF/content/welcome.jsp</result> </action> <action name="*"> <result>/WEB-INF/content/{1}.jsp</result> </action> </package> </struts>

为什么struts2 在web.xml中写了filter就不能打开jsp文件了

其中jsp文件放在F:\tomcat\webapps\2 web.xml放在F:\tomcat\webapps\2\WEB-INF //web.xml中的filter <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>/2/*.action</url-pattern> </filter-mapping>

如何通过DWR框架调用struts2中action中的方法

RT ,谢谢各位了! 我用 <create creator="new" javascript="userManager"> <param name="class" value="com.squall.oa.action.UserAction" /> <include method="checkLogin"/> </create> 这样的话不行,报服务器端的错误, 调用service层和dao层的我会使用了,只想看一下一般在项目中如果调用action中的方法的话,应该如何写? [b]问题补充:[/b] 这个是我刚写的一个Class (已经脱离action) public class UserLogin { private String randomCode; private String tag; @Autowired @Qualifier("userService") private IUserService userService; public String checkLogin(User myUser){ if (randomCode.equals(getSession().getAttribute("randomCode").toString())){ if(userService.checkLogin(myUser)){ tag = "success"; } else{ tag = "failed"; } } else{ tag = "noRandNo"; } return tag; } private HttpSession getSession() { return ServletActionContext.getRequest().getSession(); } } 然后我去配置dwr.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" "http://getahead.org/dwr/dwr20.dtd"> <dwr> <allow> <convert converter="bean" match="com.squall.oa.model.User" javascript="myUser"/> <create creator="new" javascript="userManager"> <param name="class" value="com.squall.oa.dwr.UserLogin"/> <include method="checkLogin"/> </create> </allow> </dwr> 下面是JSP页面的代码: function validateUser(){ var username,password,result; var myUser = {}; username = $("uname").value; password = $("upass").value; myUser.u_name = username; myUser.u_pass = password; userManager.checkLogin(myUser,callBackLogin) if ("success" == result){ alert('用户名密码正确!'); return true; }else if ("failed" == result){ alert('用户名密码错误!'); return false; }else { alert('验证码错误!'); return false; } } function callBackLogin(data){ alert(data); result = data; } 我其实就是为了多传到dwr中 验证码 字符串, 但是这样写 就报告了如下的错误: [b]a server error has Occured . More information may be available in the console[/b] 但是Console里 什么服务端的异常都没有~ [b]问题补充:[/b] 哦您说的对!~~ 那您看这个问题该如何解决为最佳呢? 我应该如何去设计这个验证码的字段? 把它传进service方法里么? [b]问题补充:[/b] 好的, 我刚才测试了一下 /** * @日期: Aug 21, 2009 * * @作者: 翟立虎 */ package com.squall.oa.dwr; import javax.servlet.http.HttpSession; import org.apache.struts2.ServletActionContext; import com.squall.oa.model.User; import com.squall.oa.service.IUserService; public class UserLogin { private String randomCode; private String tag; // @Autowired // @Qualifier("userService") // private IUserService userService; public String checkLogin(User myUser){ if (randomCode.equals(getSession().getAttribute("randomCode").toString())){ if(1==1){ tag = "success"; } else{ tag = "failed"; } } else{ tag = "noRandNo"; } return tag; } private HttpSession getSession() { return ServletActionContext.getRequest().getSession(); } } 我写了个测试类,如果不使用Session 那么就不会报告那个错误, 如果使用了, 还会出现那个错误 哎,我真是头疼,那我通过什么方法,得到Session,拿到验证码, 而且还不会报错呢? 非常感谢您!! 就差这点儿问题了!~~ [b]问题补充:[/b] 这样做的话,那么前台的JS怎么写传值呢? 我对回调也不是理解很深,谢谢了~~ userManager.checkLogin(myUser,<%=session%>,callBackLogin); 我这样写好像不行~ [b]问题补充:[/b] 我测试过了,还是不行,报刚才的错误~~ 哎,谢谢您了,不行的话 我就绕过这个验证码吧,传到service层里判断算了!~ [b]问题补充:[/b] 谢谢楼上两位详解了!

My eclipse 10Struts2运行出错

严重: Error loading WebappClassLoader delegate: false repositories: /WEB-INF/classes/ ----------> Parent Classloader: org.apache.catalina.loader.StandardClassLoader@6c4fc156 org.apache.struts.action.ActionServlet java.lang.ClassNotFoundException: org.apache.struts.action.ActionServlet 2017-6-2 9:02:51 org.apache.catalina.core.StandardContext loadOnStartup 严重: Servlet /Prj24_1 threw load() exception java.lang.ClassNotFoundException: org.apache.struts.action.ActionServlet at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1083) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4042) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4348) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:719) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:566) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) 2017-6-2 9:02:52 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info 信息: Parsing configuration file [struts-default.xml] 2017-6-2 9:02:52 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info 信息: Parsing configuration file [struts-plugin.xml] 2017-6-2 9:02:52 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info 信息: Parsing configuration file [struts.xml] 2017-6-2 9:02:52 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error 严重: Dispatcher initialization failed Unable to load configuration. - action - file:/D:/Users/user/Workspaces/MyEclipse%2010/.metadata/.me_tcat/webapps/StaffManagement/WEB-INF/classes/struts.xml:15:71 2017-6-2 9:02:52 org.apache.catalina.core.StandardContext start 严重: Error filterStart 2017-6-2 9:02:52 org.apache.catalina.core.StandardContext start 严重: Context [/StaffManagement] startup failed due to previous errors 2017-6-2 9:02:53 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info 信息: Parsing configuration file [struts-default.xml] 2017-6-2 9:02:53 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info 信息: Parsing configuration file [struts-plugin.xml] 2017-6-2 9:02:53 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info 信息: Parsing configuration file [struts.xml] 2017-6-2 9:02:54 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info 信息: Parsing configuration file [struts-default.xml] 2017-6-2 9:02:54 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info 信息: Parsing configuration file [struts-plugin.xml] 2017-6-2 9:02:54 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info 信息: Parsing configuration file [struts.xml] 2017-6-2 9:02:55 org.apache.coyote.http11.Http11Protocol start 信息: Starting Coyote HTTP/1.1 on http-8080 2017-6-2 9:02:55 org.apache.jk.common.ChannelSocket init 信息: JK: ajp13 listening on /0.0.0.0:8009 2017-6-2 9:02:55 org.apache.jk.server.JkMain start 信息: Jk running ID=0 time=0/14 config=null 2017-6-2 9:02:55 org.apache.catalina.startup.Catalina start 信息: Server startup in 6329 ms

struts2 页面间跳转问题

struts2的配置 struts.xml核心配置 ``` package name="app" extends="struts-default" namespace="/"> <!-- app/模块/类名/方法名 --> <action name="app/*/*/*" class="com.demo.app.{1}.action.{2}Action" method="{3}"> <result name="defaultView">app/index/index/{3}.jsp</result> <result name="view">/WEB-INF/jsp/{1}/{2}/${nextPath}.jsp</result> </action> </package> ``` Action调用方法,访问的uri=app/index/index/login ``` /* public String login(ServletRequest request,ServletResponse response){ */ public String login() throws NoSuchAlgorithmException, UnsupportedEncodingException{ HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); logger.info("action_uri=="+request.getRequestURI()); HttpSession session = request.getSession(); User userExsit = (User) session.getAttribute("user"); if (userExsit != null) { return view("recruitDetail"); } else { String loginname = request.getParameter("mobile"); String password = request.getParameter("password"); User us = loginService.findByUserName(loginname); if (us != null && us.getLoginPwd() != null && MD5Util.validPasswd(password, us.getLoginPwd())) { return view("recruitDetail");-----------(成功执行这条语句,且struts.xml中的${nextPath}值为recruitDetail) } else { return view("login"); } } } return 语句用到的view()方法 public String view(String vPath){ nextPath = vPath; logger.debug("动作完成后,转发到:" + nextPath); this.assign("timeStr", "" + System.currentTimeMillis() + System.nanoTime()); this.assign("uuid", UUIDUtil.get32ID());// 为页面传递UUID,用于页面的标识 return "view"; } ``` 结果是,我点击登陆后,在调试页面获得了要跳转页面如图: ![![图片说明](https://img-ask.csdn.net/upload/201703/12/1489293514_462880.jpg)图片说明](https://img-ask.csdn.net/upload/201703/12/1489293502_521445.jpg) 我的问题是要跳转的页面已经可以在页面debug中查到,说明访问路径没问题,怎么就没有将原来的页面覆盖掉呢,请大神们帮忙解答下,小弟谢谢了,纠结半天了

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

点沙成金:英特尔芯片制造全过程揭密

“亚马逊丛林里的蝴蝶扇动几下翅膀就可能引起两周后美国德州的一次飓风……” 这句人人皆知的话最初用来描述非线性系统中微小参数的变化所引起的系统极大变化。 而在更长的时间尺度内,我们所生活的这个世界就是这样一个异常复杂的非线性系统…… 水泥、穹顶、透视——关于时间与技艺的蝴蝶效应 公元前3000年,古埃及人将尼罗河中挖出的泥浆与纳特龙盐湖中的矿物盐混合,再掺入煅烧石灰石制成的石灰,由此得来了人...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

外包程序员的幸福生活

今天给你们讲述一个外包程序员的幸福生活。男主是Z哥,不是在外包公司上班的那种,是一名自由职业者,接外包项目自己干。接下来讲的都是真人真事。 先给大家介绍一下男主,Z哥,老程序员,是我十多年前的老同事,技术大牛,当过CTO,也创过业。因为我俩都爱好喝酒、踢球,再加上住的距离不算远,所以一直也断断续续的联系着,我对Z哥的状况也有大概了解。 Z哥几年前创业失败,后来他开始干起了外包,利用自己的技术能...

C++11:一些微小的变化(新的数据类型、template表达式内的空格、nullptr、std::nullptr_t)

本文介绍一些C++的两个新特性,它们虽然微小,但对你的编程十分重要 一、Template表达式内的空格 C++11标准之前建议在“在两个template表达式的闭符之间放一个空格”的要求已经过时了 例如: vector&lt;list&lt;int&gt; &gt;; //C++11之前 vector&lt;list&lt;int&gt;&gt;; //C++11 二、nullptr ...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

深入剖析Springboot启动原理的底层源码,再也不怕面试官问了!

大家现在应该都对Springboot很熟悉,但是你对他的启动原理了解吗?

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

【阿里P6面经】二本,curd两年,疯狂复习,拿下阿里offer

二本的读者,在老东家不断学习,最后逆袭

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《经典算法案例》01-08:如何使用质数设计扫雷(Minesweeper)游戏

我们都玩过Windows操作系统中的经典游戏扫雷(Minesweeper),如果把质数当作一颗雷,那么,表格中红色的数字哪些是雷(质数)?您能找出多少个呢?文中用列表的方式罗列了10000以内的自然数、质数(素数),6的倍数等,方便大家观察质数的分布规律及特性,以便对算法求解有指导意义。另外,判断质数是初学算法,理解算法重要性的一个非常好的案例。

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

正确选择比瞎努力更重要!

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

微软为一人收购一公司?破解索尼程序、写黑客小说,看他彪悍的程序人生!...

作者 | 伍杏玲出品 | CSDN(ID:CSDNnews)格子衬衫、常掉发、双肩包、修电脑、加班多……这些似乎成了大众给程序员的固定标签。近几年流行的“跨界风”开始刷新人们对程序员的...

终于,月薪过5万了!

来看几个问题想不想月薪超过5万?想不想进入公司架构组?想不想成为项目组的负责人?想不想成为spring的高手,超越99%的对手?那么本文内容是你必须要掌握的。本文主要详解bean的生命...

我说我懂多线程,面试官立马给我发了offer

不小心拿了几个offer,有点烦

自从喜欢上了B站这12个UP主,我越来越觉得自己是个废柴了!

不怕告诉你,我自从喜欢上了这12个UP主,哔哩哔哩成为了我手机上最耗电的软件,几乎每天都会看,可是吧,看的越多,我就越觉得自己是个废柴,唉,老天不公啊,不信你看看…… 间接性踌躇满志,持续性混吃等死,都是因为你们……但是,自己的学习力在慢慢变强,这是不容忽视的,推荐给你们! 都说B站是个宝,可是有人不会挖啊,没事,今天咱挖好的送你一箩筐,首先啊,我在B站上最喜欢看这个家伙的视频了,为啥 ,咱撇...

立即提问
相关内容推荐