Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: STRUTS 2: Could not find action or result

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default STRUTS 2: Could not find action or result

    hiii everyone..i am new to struts 2 framework...i developed my jsp code into sturts framework...but its showing some warning and the "menujsp.jsp" page is not opening...its showing the following on my log in eclipse:

    WARNING: Could not find action or result
    There is no Action mapped for namespace [/] and action name [menujsp] associated with context path [/Basic]. - [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.c reateActionProxy(StrutsActionProxyFactory.java:39)
    at com.opensymphony.xwork2.DefaultActionProxyFactory. createActionProxy(DefaultActionProxyFactory.java:5 8)
    at org.apache.struts2.dispatcher.Dispatcher.serviceAc tion(Dispatcher.java:500)
    at org.apache.struts2.dispatcher.ng.ExecuteOperations .executeAction(ExecuteOperations.java:77)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrep areAndExecuteFilter.doFilter(StrutsPrepareAndExecu teFilter.java:91)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invo ke(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.invok e(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:447)
    at java.lang.Thread.run(Unknown Source)


    Following are the contents of my application:

    ConnectionProvider.java



    package pkg;
    import java.sql.Connection;
    import java.sql.DriverManager;

    public class ConnectionProvider
    {
    public static Connection getConnection(){
    Connection con=null;
    try{
    Class.forName("org.postgresql.Driver");
    con=DriverManager.getConnection("jdbc:postgresql://localhost:5433/labway","postgres","sachin");
    }
    catch(Exception e){
    System.out.println(e);
    }
    return con;
    }
    }



    DAO.java:

    package pkg;

    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.util.*;

    public class DAO
    {
    public List<MenuList> fetch(){
    try{
    Connection con=ConnectionProvider.getConnection();
    PreparedStatement stmt=con.prepareStatement("select * from application where application_id in (select distinct application_id from applicationmenu order by application_id)");
    ResultSet rs=stmt.executeQuery();
    ResultSet rs1=null;
    MenuList menulist;
    List<MenuList> list=new ArrayList<MenuList>();
    while(rs.next()){
    menulist=new MenuList();
    menulist.setmenuId(rs.getString(1));
    menulist.setmenuTitle(rs.getString(3));
    PreparedStatement stmt1=con.prepareStatement("select * from menu where menu_id in (select menu_id from applicationmenu where application_id='"+rs.getString(1)+"')");
    rs1=stmt1.executeQuery();
    menulist.setsubmenuTitle(rs1.getString(3));

    list.add(menulist);
    }
    return list;
    }
    catch(Exception e)
    {
    System.out.println(e);
    }
    return null;
    }



    "MenuList.java":


    package pkg;

    public class MenuList {
    String menuId;
    String menuTitle;
    String submenuTitle;
    public MenuList()
    {
    super();
    }
    public MenuList(String menuId,String menuTitle,String submenuTitle)
    {
    super();
    this.menuId=menuId;
    this.menuTitle=menuTitle;
    this.submenuTitle=submenuTitle;
    }
    public String getMenuId()
    {
    return menuId;
    }
    public String getmenuTitle()
    {
    return menuTitle;
    }
    public String submenuTitle()
    {
    return submenuTitle;
    }
    public void setmenuId(String menuId)
    {
    this.menuId = menuId;
    }
    public void setmenuTitle(String menuTitle)
    {
    this.menuTitle = menuTitle;
    }
    public void setsubmenuTitle(String submenuTitle)
    {
    this.submenuTitle = submenuTitle;
    }
    }






    MenuListAction.java:


    package pkg;
    import java.util.*;
    import com.opensymphony.xwork2.ActionSupport;
    public class MenuListAction extends ActionSupport
    {
    private MenuList menulist;
    private List<MenuList> menulistlist;
    DAO dao=new DAO();
    public String execute()
    {
    menulistlist=dao.fetch();
    return "success";
    }
    public MenuList getMenulist()
    {
    return menulist;
    }
    public void setMenulist(MenuList menulist)
    {
    this.menulist = menulist;
    }
    public List<MenuList> getMenulistlist()
    {
    return menulistlist;
    }
    public void setMenulistlist(List<MenuList> menulistlist)
    {
    this.menulistlist = menulistlist;
    }

    }




    web.xml :


    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlnssi="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">

    <welcome-file-list>
    <welcome-file>index</welcome-file>
    </welcome-file-list>
    <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.Stru tsPrepareAndExecuteFilter
    </filter-class>
    </filter>
    <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</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.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">
    <struts>

    <constant name="struts.devMode" value="true"></constant>

    <package name="Basic" extends="struts-default">
    <action name="fetch" class="pkg.MenuListAction" method="execute">

    <result name="success" >/menujsp.jsp</result>
    </action>

    </package>
    </struts>



    index.jsp :



    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@taglib uri="/struts-tags" prefix="s" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <head><title>DYNAMIC DROPDOWN MENU</title></head>
    <body><br><br><center>

    <a href="menujsp.jsp">Home Page</a>

    </center>
    </body>
    </html>



    menujsp.jsp :

    <%@ taglib prefix="s" uri="/struts-tags" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <style>

    body{
    background-image:ur(C:\indian-flag-12.gif) no-repeat ;
    font-family:arial;}
    table{font-size:80%;background:black}
    a{color:black;text-decoration:none;font:bold}
    a:hover{color:#606060}
    td.menu{background:lightgrey}
    table.menu
    {
    font-size:100%;
    position:absolute;
    visibility:hidden;
    }
    </style>
    <script type="text/javascript">
    function showmenu(elmnt)
    {
    document.getElementById(elmnt).style.visibility="v isible";
    }
    function hidemenu(elmnt)
    {
    document.getElementById(elmnt).style.visibility="h idden";
    }
    </script>
    </head>

    <body>
    <h3>EMPLOYMENT EXCHANGE Test Page</h3>
    <table width="100%">
    <tr bgcolor="#FG8080">
    <s:iterator value="menulistlist" var="menulist">
    <td onmouseover="showmenu(<s:property value="#parent.menuId"/>)" onmouseout="hidemenu(<s:property value="#parent.menuId"/>)">
    <a href="/default.asp"><s:property value="#parent.menuTitle"/></a><br />
    <table class="menu" id="<s:property value="#parent.menuId"/>" width="120">
    <s:iterator value="menulistlist" var="menulist">
    <tr><td class="menu" id="<s:property value="#parent.menuId"/>"><a href="/html/default.asp"><s:property value="submenuTitle"/></a></td></tr>
    </s:iterator>
    </s:iterator>

    </table>
    </td>

    </body>

    </html>



    plzz help me out...i might have problem in my struts.xml...its not mapping with the action resource
    my menujsp.jsp code must also be incorrect but thats another issue...first i need to display this jsp whic isn't happening...
    regards
    Sachin


  2. #2
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: STRUTS 2: Could not find action or result

    Please provide SSCCE

  3. #3
    Member
    Join Date
    Dec 2011
    Posts
    50
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default Re: STRUTS 2: Could not find action or result

    In Struts.xml you specified the action's name is "fetch", however the exception log says it could not find "/Basic".

  4. #4
    Junior Member
    Join Date
    Feb 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: STRUTS 2: Could not find action or result

    this one's working now...der was some problem in DAO.java. thnks for the help

Similar Threads

  1. newbie question: Error: Could not find or load main class Java Result: 1
    By ideaman in forum What's Wrong With My Code?
    Replies: 6
    Last Post: January 1st, 2012, 11:40 PM
  2. Implementing Sha256 and not getting the result I should get
    By ydan87 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: December 26th, 2011, 03:30 PM
  3. Result set is closed
    By keshav_agrawal89 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: June 11th, 2011, 08:35 AM
  4. [NEED HELP] to clear result on my tic-tac-toe game
    By bontet in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 28th, 2010, 03:50 PM
  5. result set array button
    By dread_arisawa in forum What's Wrong With My Code?
    Replies: 2
    Last Post: August 21st, 2010, 10:05 AM