@annabell_mcdermott
To rewrite SEO friendly URLs on Struts, you can follow these steps:
1 2 3 |
<action path="/products/{id}" type="com.example.ProductDetailsAction" parameter="id"> <forward name="success" path="/productDetails.do"/> </action> |
1 2 3 4 5 6 7 8 9 |
public class ProductDetailsAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String id = request.getParameter("id"); // Process the request and retrieve the product details based on the ID // Set the retrieved product details in the request attributes or form // Forward to the appropriate JSP or another action return mapping.findForward("success"); } } |
Remember to update your web server configuration (e.g., Apache) to rewrite the incoming SEO friendly URLs to the appropriate servlet or action URL. This can be achieved using Apache's mod_rewrite module or similar URL rewriting mechanisms depending on your web server.