S2SH整合问题,高手来,高分求解!

杜乐 2010-12-16 01:01:34
S2SH刚整合到S就报错了。
2010-12-16 13:01:05 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find action or result
There is no Action mapped for namespace / and action name login. - [unknown location]
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:177)
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:47)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:458)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:76)
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:175)
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:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)

这是Tomcat启动时的警告
2010-12-16 13:00:30 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: C:\Program Files\Java\jre1.6.0\bin;C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.16\bin
2010-12-16 13:00:30 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2010-12-16 13:00:30 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 662 ms
2010-12-16 13:00:30 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2010-12-16 13:00:30 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.16
2010-12-16 13:00:31 org.apache.catalina.core.StandardContext addApplicationListener
信息: The listener "listeners.ContextListener" is already configured for this context. The duplicate definition has been ignored.
2010-12-16 13:00:31 org.apache.catalina.core.StandardContext addApplicationListener
信息: The listener "listeners.SessionListener" is already configured for this context. The duplicate definition has been ignored.
2010-12-16 13:00:31 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
2010-12-16 13:00:31 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
2010-12-16 13:00:32 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [struts-default.xml]
2010-12-16 13:00:32 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Unable to locate configuration files of the name struts-plugin.xml, skipping
2010-12-16 13:00:32 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [struts-plugin.xml]
2010-12-16 13:00:32 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Unable to locate configuration files of the name /WEB-INF/conf/struts2/struts.xml, skipping
2010-12-16 13:00:32 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [/WEB-INF/conf/struts2/struts.xml]
2010-12-16 13:00:33 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2010-12-16 13:00:33 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2010-12-16 13:00:33 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/47 config=null
2010-12-16 13:00:33 org.apache.catalina.startup.Catalina start
信息: Server startup in 2652 ms
2010-12-16 13:00:34 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: No configuration found for the specified action: 'login' in namespace: ''. Form action defaulting to 'action' attribute's literal value.
2010-12-16 13:00:35 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: No configuration found for the specified action: 'login' in namespace: ''. Form action defaulting to 'action' attribute's literal value.

这是我的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="struts2" extends="struts-default">
<action name="login" class="com.dule.s2sh.test.Test">
<result name="success" type="redirect">index.jsp</result>
<result name="input">login.jsp</result>
<result name="error">error.html</result>
</action>
</package>
</struts>

这是我的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">
<!-- 过滤器 -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<!-- Struts2配置文件 -->
<init-param>
<param-name>config</param-name>
<param-value>
struts-default.xml,
struts-plugin.xml,
/WEB-INF/conf/struts2/struts.xml
</param-value>
</init-param>
<!-- Struts2配置文件结束 -->
</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>

这是我的Test.java文件

package com.dule.s2sh.test;

import com.opensymphony.xwork2.ActionSupport;

public class Test extends ActionSupport {

public String loginName;
public String loginPassword;

public String execute() {
if (!loginName.equals("admin")) {
super.addFieldError(loginName, "用户名错误!");
return ERROR;
}
if (!loginPassword.equals("123")) {
super.addFieldError(loginPassword, "密码错误!");
return ERROR;
}
return SUCCESS;
}

public void validate() {
if (loginName == null || loginName.length() == 0) {
super.addFieldError(loginName, "用户名不能为空!");
}
if (loginPassword == null || loginPassword.length() == 0) {
super.addFieldError(loginPassword, "密码不能为空!");
}
}

}
...全文
169 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
qianyecq 2010-12-16
  • 打赏
  • 举报
回复
Struts2 支持跟命名空间("/"),当一个request 直接请求context path 下面的资源时,struts2 会首先到跟命名空间下去寻找匹配的action,例如请求是http://server/myapp/bar.action,那么我们首先会去”/”命名空间下去寻找这个action。

具体的看这里:
http://struts2.group.javaeye.com/group/blog/783409
杜乐 2010-12-16
  • 打赏
  • 举报
回复
namesoace="/"是什么意思了?
qianyecq 2010-12-16
  • 打赏
  • 举报
回复
漏了配置命名空间,在struts.xml中配置:

<package name="" extends="struts-default" namespace="/">
qianyecq 2010-12-16
  • 打赏
  • 举报
回复
<package name="" extends="struts-default" namespace="/">
杜乐 2010-12-16
  • 打赏
  • 举报
回复
在哪儿定义呢?我刚开始学s2sh
liqi_wj 2010-12-16
  • 打赏
  • 举报
回复
得需要定义namespace把
杜乐 2010-12-16
  • 打赏
  • 举报
回复
定义了login了
magong 2010-12-16
  • 打赏
  • 举报
回复
[Quote=引用楼主 tydule 的回复:]
警告: Could not find action or result
There is no Action mapped for namespace / and action name login. - [unknown location]
[/Quote]
你的struts.xml文件中没有定义叫做login的action
wcl_friend 2010-12-16
  • 打赏
  • 举报
回复
应该有人可以帮你解决问题的。
wcl_friend 2010-12-16
  • 打赏
  • 举报
回复
Struts2.0很久都没用了,都快忘光了。

LZ感兴趣可以加入59673719(IT精英),大家相互交流,相互学习。

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧