Could not execute action: /mainaction

J2EE 码拜 10年前 (2015-04-23) 3150次浏览 0个评论

问题:如下

014-9-27 14:17:04 org.apache.catalina.core.AprLifecycleListener init
信息: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: E:\anzhuangbao\MyEclipse\bin;E:\anzhuangbao\MyEclipse\myeclipse\eclipse\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_6.5.0.zmyeclipse650200806\tomcat\bin
2014-9-27 14:17:04 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2014-9-27 14:17:04 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 846 ms
2014-9-27 14:17:04 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2014-9-27 14:17:04 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.13
2014-9-27 14:17:09 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
2014-09-27 14:17:17,212 WARN  [Settings.java:143] : Settings: Could not parse struts.locale setting, substituting default VM locale
2014-9-27 14:17:18 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2014-9-27 14:17:18 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2014-9-27 14:17:19 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/37  config=null
2014-9-27 14:17:19 org.apache.catalina.startup.Catalina start
信息: Server startup in 14241 ms
2014-09-27 14:18:28,107 ERROR [ActionComponent.java:259] : Could not execute action: /mainaction
There is no Action mapped for action name mainaction. – [unknown location]
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:186)
at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:41)
at org.apache.struts2.components.ActionComponent.executeAction(ActionComponent.java:249)

JSP界面:

<center>
<s:action name=”mainaction” executeResult=”false”></s:action>
<div id=”right”>
    <ul class=”list”>
     <li class=”listTitle”>
        最新上架<a class=”more”>更多..</a>
     </li>
<s:iterator value=”#request.newbookList” status=”st”>
<li class=”listPicture”>
<a href=”singleBook.jsp?bookId=<s:property value=”lid” />”><img src=””upload/<s:property value=”lpricture” />””/></a>
</li>
<li class=”listMaessage”>
<a class=”bookName” href=”singleBook.jsp?bookId=<s:property value=”bookId” />”><s:property value=”lname” /></a><br/><br/>
作者:<a class=”bookStyle” href=”oneType.jsp?searchType=bookAuthor&searchDescribe=<s:property value=”lauthor”/>”><s:property value=”lauthor”/></a><br/><br/>
出版社:<a class=”bookStyle” href=”oneType.jsp?searchType=bookPress&searchDescribe=<s:property value=”lpress”/>”><s:property value=”lpress”/></a><br/><br/>
类别:<a class=”bookStyle” href=”oneType.jsp?searchType=bookType&searchDescribe=<s:property value=”ltype”/>”><s:property value=”ltype”/></a><br/><br/>
</li>
</s:iterator>
    </ul>

struts 配置界面如下

<?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>
    <constant name=”struts.enable.DynamicMethodInvocation” value=”false” />
    <constant name=”struts.objectFactory” value=”spring” />
    <constant name=”struts.devMode” value=”false” />
    <constant name=”struts.locale” value=”en_UTF-8″ />
    <package name=”default” namespace=”/” extends=”struts-default”>
    <!– 登录判断 –>
        <action name=”adenglu” class=”actionclass” method=”denglu”>
                <result name=”userok”>user.jsp</result>
                <result name=”adminok”>/admin/admin.jsp</result>
                <result name=”error”>error.jsp</result>
        </action>
    <!– 判断昵称是否唯一,然后注册新用户 –>
        <action name=”aselectname” class=”actionclass” method=”selectname”>
                <result name=”UserRegisterOk”>error.jsp</result>
                <result name=”error”>error.jsp</result>
        </action>
    <!– 退出用户登录 –>
        <action name=”aExitLogin” class=”actionclass” method=”ExitLogin”>
                <result name=”AdminExitLoginOk”>enter.jsp</result>
                <result name=”UserExitLoginOk”>login.jsp</result>
                <result name=”error”>error.jsp</result>
        </action> 
        
        
        
        
        <action name=”mainaction” class=”mainAction” >
        </action>
 

application。。。。配置界面:

<bean id=”bookQ” class=”query.bookQuery” abstract=”false” 
    lazy-init=”default” autowire=”default” dependency-check=”default”>
<property name=”sessionFactory”>
<ref local=”sessionFactory” />
</property>
</bean>

<bean id=”mainAction” class=”com.onlinebookstore.action.mainAction” scope=”protoType”>
    <property name=”bookQ”>
<ref bean=”bookQ” />
</property>
</bean>

Action  界面:

public class mainAction extends ActionSupport{
private bookQuery bookQ;
public void setBookQ(bookQuery bookQ) {
this.bookQ = bookQ;
}
public String execute(){
// 最新上架
System.out.println(“ceshi”);
List newbookList=bookQ.newbook(1, 6);
HttpServletRequest request=ServletActionContext.getRequest();
request.setAttribute(“newbookList”, newbookList);
return null;
}
}

 bookQuery  代码:

//显示最新上架的图书
public List newbook(int pageNumber, int pageSize) {    //List<Library>   标明将结果及转换成 Library 型
String sql = “from Library l where l.lsum > 0 order by l.lshelvetime desc “;
try 
{
List newbook = this.getHibernateTemplate().find(sql);
return newbook;

catch (RuntimeException re) 
{
throw re;
}
}
}

请大神帮帮忙,分析一下这是什么原因!早上起床,就开始调现在还没有吃饭了,小弟先去吃个饭哈!有劳大神啦!  如果程序这样分析不出来原因,小弟可提供源码及数据库供大神分析!    

Could not execute action: /mainaction
10分
Struts 与 Spring 的集成代码写在哪里的?
Could not execute action: /mainaction
什么意思?小弟不太懂。。  代码都在上面了
Could not execute action: /mainaction
<action name=”mainaction” class=”mainAction” >
        </action> 

我咋记得得用完整包名呢???

Could not execute action: /mainaction
40分
这个错感觉似曾相识,但就是没看出那里的问题,先帮顶一下!

建议以后代码都放代码框里,这个看着太费劲了。

关注一下!

Could not execute action: /mainaction
引用 4 楼 cgw1123 的回复:

这个错感觉似曾相识,但就是没看出那里的问题,先帮顶一下!

建议以后代码都放代码框里,这个看着太费劲了。

关注一下!

小弟已经解决了,不过是换了另外一种方法。谢谢大神

Could not execute action: /mainaction
怎么解决的啊。楼主

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明Could not execute action: /mainaction
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!