java - Struts2 with maven no Action mapped for namespace and action name associated with context path -
although common problem cannot figure out.
i running strut2 maven project. project structure given bellow
product.java
package beans; public class product { private int id; private string name; private float price; public int getid() { return id; } public void setid(int id) { this.id = id; } public string getname() { return name; } public void setname(string name) { this.name = name; } public float getprice() { return price; } public void setprice(float price) { this.price = price; } }
productaction.java
package actions; import beans.product; public class productaction{ public product getproduct() { return product; } public void setproduct(product product) { this.product = product; } private product product; public string execute(){ return "success"; } }
struts.xml
<?xml version="1.0" encoding="utf-8" ?> <!doctype struts public "-//apache software foundation//dtd struts configuration 2.1//en" "http://struts.apache.org/dtds/struts-2.1.dtd"> <struts> <constant name="struts.devmode" value="true" /> <package name="default" namespace="/" extends="struts-default"> <action name="product" class="actions.productaction" method="execute"> <result name="success">welcome.jsp</result> </action> </package> </struts>
web.xml
<!doctype web-app public "-//sun microsystems, inc.//dtd web application 2.3//en" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app> <display-name>archetype created web application</display-name> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.ng.filter.strutsprepareandexecutefilter </filter-class> </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>
index.jsp
<html> <body> <h2>hello world!</h2> <div> <%@ taglib uri="/struts-tags" prefix="s" %> <s:form action="product"> <s:textfield name="product.id" label="product id"></s:textfield> <s:textfield name="product.name" label="product name"></s:textfield> <s:textfield name="product.price" label="product price"></s:textfield> <s:submit value="save"></s:submit> </s:form> </div> </body> </html>
and welcome.jsp
<%@ page contenttype="text/html;charset=utf-8" language="java" %> <html> <head> <title></title> </head> <body> <%@ taglib uri="/struts-tags" prefix="s" %> product id:<s:property value="id"/><br/> product name:<s:property value="name"/><br/> product price:<s:property value="price"/><br/> </body> </html>
i using glassfish server. runs index.jsp well. when fill form , submit shows
http status 404 - there no action mapped namespace [/] , action name [product] associated context path [/deploytest].
type status report
messagethere no action mapped namespace [/] , action name [product] associated context path [/deploytest].
descriptionthe requested resource not available.
glassfish server open source edition 4.1.1
my pom.xml has dependency
<dependency> <groupid>org.apache.struts</groupid> <artifactid>struts2-core</artifactid> <version>2.3.28</version> </dependency>
Comments
Post a Comment