Domanda

I have a page with a link to redirect to a struts action, the action works fine when I redirect through URL Action. I need to call that action again, at that time the context path shows an error. If I give that in namespace the URL action messes up. How to solve this?

The files are here:

index.jsp:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Online Test Taking System</title>
</head>
<body>
<s:url action="viewuncomputedlist.action" var="viewremlist" />

<a href="<s:url action='viewuncomputedlist'/>"> Here you GO! </a>
</body>
</html>

struts.xml:

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

<struts>
<package name="user" namespace="/" extends="struts-default">
    <action name="compute" class="com.action.ComputeScore" method="computeMethod">
        <result name="redirect" type="chain">viewuncomputedlist</result>
    </action>
    <action name="viewuncomputedlist" class="com.action.FetchRemUser">
        <result name="success">viewList.jsp</result>
    </action>
</package>
</struts>

When I call the action in some submit form it calls it directly from the WebContent. But all the JSP files are in WebContent/jsp/rams/result/.

È stato utile?

Soluzione

You should use absolute path names to the JSPs, unless you know what are you doing

<result name="success">/jsp/rams/result/viewList.jsp</result>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top