關於javascript 呼叫 struts action 問題
請問 JSP 如何在沒有任何觸發的狀態下執行 stuts 的 action 動作
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
我的stuts-config.xml
<action
attribute="testForm"
input="/form/testDelete.jsp"
name="testForm"
path="/testDelete"
scope="request"
type="com.database_v30.struts.action.TestAction">
<set-property property="cancellable" value="true" />
<forward
name="fail"
path="/form/processFail.jsp"
redirect="true" />
<forward name="success" path="/form/testReview.jsp" />
</action>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
其中 testDelete.jsp
<body>
<%
if (一些條件判斷) {
out.print(" <script language='javascript'>window.location='/testDelete.do'; </script>");
}
%>
</body>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
其中 TestAction.java
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
TestForm testForm = (TestForm) form;
刪除動作...
return mapping.findForward("success");
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
請問那裡出問題了? testDelete.jsp有進去,但是卻跳不進action裡做動作...
請大家幫幫忙!謝謝~
------解决方案--------------------
其中 testDelete.jsp
<body>
<%
if (一些條件判斷) {
out.print(" <script language='javascript'>window.location='/testDelete.do'; </script>");
}
%>
</body>
为什么不这样写了
<body>
<%
if (一些條件判斷) {
%>
<jsp:forward page="testDelete.do"/>
<%
}
%>
</body>
------解决方案--------------------
<jsp:jsp:forward page="/testDelete.do"/>
就相当与在浏览器地址栏中输入
http://ip:端口号/你的项目/testDelete.do
明白了吗