You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by angelwei <go...@hotmail.com> on 2008/07/31 05:26:20 UTC

Create multiple struts configuration file problem

Hai, can anybody help me to solve the problem javax.servlet.jsp.JspException:
Cannot retrieve mapping for action /pro.
if i replace the content in struts-config-product.xml to struts-config.xml.
it work. any idea???

web.xml

<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>config/product</param-name>
<param-value>/WEB-INF/product/struts-config-product.xml</param-value>
</init-param>

struts-config-product.xml (product folder)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts
Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>

<!-- Data Sources -->
<data-sources>
</data-sources>

<!-- Form Beans -->
<form-beans>
<form-bean name="productForm" type="app.ProductForm"/>
</form-beans>

<!-- Global Exceptions -->
<global-exceptions>
</global-exceptions>

<!-- Global Forwards -->
<global-forwards>
</global-forwards>

<!-- Action Mappings -->
<action-mappings>
<action path="/pro"
type="app.ProductAction"
name="productForm"
scope="request">
<forward name="success" path="/success.html"/>
</action>
</action-mappings>

</struts-config>

ProductForm.java

package app;

import org.apache.struts.action.ActionForm;

public class ProductForm extends ActionForm{
private int id;

public int getId(){
return id;
}

public void setId(int id){
this.id=id;
}
}

ProductAction.java

package app;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class ProductAction extends Action{
public ActionForward perform(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
ProductForm product=(ProductForm)form;
int iProduct=product.getId();
HttpSession session=request.getSession();
session.setAttribute("product",form);
return mapping.findForward("success");
}
}

thank you.
-- 
View this message in context: http://www.nabble.com/Create-multiple-struts-configuration-file-problem-tp18747121p18747121.html
Sent from the Struts - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Create multiple struts configuration file problem

Posted by Ted Husted <hu...@apache.org>.
The best place to post this message would be the Apache Struts user list.

 * http://struts.apache.org/mail.html
 * http://www.nabble.com/Struts---User-f206.html

HTH, Ted
http://husted.com/ted/blog/

On Wed, Jul 30, 2008 at 11:26 PM, angelwei <go...@hotmail.com> wrote:
>
> Hai, can anybody help me to solve the problem javax.servlet.jsp.JspException:
> Cannot retrieve mapping for action /pro.
> if i replace the content in struts-config-product.xml to struts-config.xml.
> it work. any idea???
>
> web.xml
>
> <init-param>
> <param-name>config</param-name>
> <param-value>/WEB-INF/struts-config.xml</param-value>
> </init-param>
> <init-param>
> <param-name>config/product</param-name>
> <param-value>/WEB-INF/product/struts-config-product.xml</param-value>
> </init-param>
>
> struts-config-product.xml (product folder)
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts
> Configuration 1.1//EN"
> "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
> <struts-config>
>
> <!-- Data Sources -->
> <data-sources>
> </data-sources>
>
> <!-- Form Beans -->
> <form-beans>
> <form-bean name="productForm" type="app.ProductForm"/>
> </form-beans>
>
> <!-- Global Exceptions -->
> <global-exceptions>
> </global-exceptions>
>
> <!-- Global Forwards -->
> <global-forwards>
> </global-forwards>
>
> <!-- Action Mappings -->
> <action-mappings>
> <action path="/pro"
> type="app.ProductAction"
> name="productForm"
> scope="request">
> <forward name="success" path="/success.html"/>
> </action>
> </action-mappings>
>
> </struts-config>
>
> ProductForm.java
>
> package app;
>
> import org.apache.struts.action.ActionForm;
>
> public class ProductForm extends ActionForm{
> private int id;
>
> public int getId(){
> return id;
> }
>
> public void setId(int id){
> this.id=id;
> }
> }
>
> ProductAction.java
>
> package app;
>
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
> import javax.servlet.http.HttpSession;
>
> import org.apache.struts.action.Action;
> import org.apache.struts.action.ActionForm;
> import org.apache.struts.action.ActionForward;
> import org.apache.struts.action.ActionMapping;
>
> public class ProductAction extends Action{
> public ActionForward perform(ActionMapping mapping, ActionForm form,
> HttpServletRequest request, HttpServletResponse response){
> ProductForm product=(ProductForm)form;
> int iProduct=product.getId();
> HttpSession session=request.getSession();
> session.setAttribute("product",form);
> return mapping.findForward("success");
> }
> }
>
> thank you.
> --
> View this message in context: http://www.nabble.com/Create-multiple-struts-configuration-file-problem-tp18747121p18747121.html
> Sent from the Struts - Dev mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org