本帖最后由 rabphitozhou 于 2010-04-08 11:53:31 编辑

解决方案 »

  1.   

    在哪不能运行的,用alert一行一行的调试,或者找工具调试一下
      

  2.   

    你最好把result.jsp下面的body中加点东西,你应该不是跳转到result.jsp中
      

  3.   

    楼主用firefox浏览一下看看,firebug提示哪行报错,之后再来贴代码
      

  4.   

    应该是根本就没有执行到result.jsp吧,配置文件错误
      

  5.   

    我重新贴一下完整代码,前面比较急。
    ------------------------------------------------------------------
    index.jsp的代码:
    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
    <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
    <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
    <%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>My JSP 'index.jsp' starting page</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->  </head>
      
      <body>
        <html:link action="/quiz.do">开始</html:link>
      
    <br>
      </body>
    </html>------------------------------------------------------------------------
    struts-config.xml的内容:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd"><struts-config>
      <form-beans >
        <form-bean name="quizForm" type="com.exam.struts.form.QuizForm" />  </form-beans>
    <global-exceptions />
      <global-forwards>
      
      </global-forwards>
      <action-mappings >
        <action
          attribute="quizForm"
          input="/form/quiz.jsp"
          name="quizForm"
          path="/quiz"
          scope="request"
          type="com.exam.struts.action.QuizAction">
          <forward name="qsNotOver" path="/form/quiz.jsp" />
        </action>  </action-mappings>------------------------------------------------------------------------
    quiz.jsp的内容:
    <%@ page language="java" pageEncoding="UTF-8"%>
    <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%> 
    <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
     
    <html:html> 
    <head>

    <title>竞赛题目</title>
    <script type="text/javascript" src="jquery-1.3.2.min.js" /><script type="text/javascript">
    $(function()
    {
    alert("ok");
    });
    </script>
    </head>
    <body>
    <html:form action="/quiz">
    <html:radio property="answer" value="1" styleId="answer1" /><html:errors property="answer"/><br/>
    <html:radio property="answer" value="2" styleId="answer2" /><html:errors property="answer"/><br/>
    <html:radio property="answer" value="3" styleId="answer3" /><html:errors property="answer"/><br/>
    <html:radio property="answer" value="4" styleId="answer4" /><html:errors property="answer"/><br/>
    <html:hidden property="id" value="${examQ[0].id}" /><html:errors property="id"/><br/>
    <html:submit styleId="bt" value="下一题" />
    </html:form>
    </body>
    </html:html>
    ---------------------------------------------------------------------------
    index页面通过action可以正常跳转到quiz.jsp页面,但是quiz.jsp页面里的js代码(alert)却无法执行,大家帮帮忙啊~
      

  6.   


    就是alert的命令也无法运行啊
      

  7.   

    add to body:
    <html>
    <head>
    <title></title></head><body>
    <script type="text/javascript">
    alert("ok");
    </script>
    </body></html>
      

  8.   

    or:
    window.onload=function(){alert("ok");}
      

  9.   

    可以的呀!!我本地 全部静态HTML 提交跳转到 result.html 可以执行 alert('ok!!');楼主看看你  JSP写的是不是有问题
      

  10.   

    问题解决如下:
    原quiz.jsp中,head标签里的代码是
    <script type="text/javascript" src="jquery-1.3.2.min.js" /><script type="text/javascript">
    $(function()
    {
    alert("ok");
    });
    </script>
    问题出在<script type="text/javascript" src="jquery-1.3.2.min.js" />,应为<script type="text/javascript" src="jquery-1.3.2.min.js"></script>,就可以运行了