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

Summary

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(DefaultActionProxy.java:185) at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63) 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:500) 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: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) 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 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(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 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 org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter 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" %>

EMPLOYMENT EXCHANGE Test Page

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">