Skip to main content

STRUTS 2: Could not find action or result

Posted by sachin.negi04 on February 2, 2012 at 10:51 PM PST


hiii..i am new to struts 2 framework...i developed my jsp code into sturs frame work...but its showing some warning and the "menujsp.jsp" page is not opening...its showing the following on my log: 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( at org.apache.struts2.impl.StrutsActionProxy.prepare( at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy( at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy( at org.apache.struts2.dispatcher.Dispatcher.serviceAction( at at at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( at org.apache.catalina.core.ApplicationFilterChain.doFilter( at org.apache.catalina.core.StandardWrapperValve.invoke( at org.apache.catalina.core.StandardContextValve.invoke( at org.apache.catalina.core.StandardHostValve.invoke( at org.apache.catalina.valves.ErrorReportValve.invoke( at org.apache.catalina.core.StandardEngineValve.invoke( at org.apache.catalina.connector.CoyoteAdapter.service( at org.apache.coyote.http11.Http11Processor.process( at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process( at$ at Source) Following are the contents of my application: 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; } } package pkg; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.*; public class DAO { public List 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 list=new ArrayList(); while({ 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; } "": 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; } } package pkg; import java.util.*; import com.opensymphony.xwork2.ActionSupport; public class MenuListAction extends ActionSupport { private MenuList menulist; private List 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 getMenulistlist() { return menulistlist; } public void setMenulistlist(List menulistlist) { this.menulistlist = menulistlist; } } web.xml : index struts2 struts2 /* struts.xml : /menujsp.jsp index.jsp : <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@taglib uri="/struts-tags" prefix="s" %> DYNAMIC DROPDOWN MENU

Home Page
menujsp.jsp : <%@ taglib prefix="s" uri="/struts-tags" %>


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

)" onmouseout="hidemenu()">
" width="120">