标题:为什么这段代码不显示输入框而直接跳转到了错误页面
只看楼主
蓝域小兵
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2016-4-28
 问题点数:0 回复次数:0 
为什么这段代码不显示输入框而直接跳转到了错误页面

这是主页面代码
程序代码:
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www. <title>one</title>
    <jsp:include page="head.txt" />
</head>
<body bgcolor="yellow">
    <embed src="f:\1.mp3" />
    <form method="post" name="form">
        请输入1到100之间的整数:
        <input type="text" name="num" value="3"/><br />
        <input type="submit" value="提交" name="submit" />
    </form>
    <jsp:include page="judge.jsp" />
</body>
</html>


judge.jsp的代码:
程序代码:
    <%
        String number;
        number=request.getParameter("num");
        if(number==null)
            number="0";
        try{
            int n=Integer.parseInt(number);
            if(n==0){
    %>            <jsp:forward page="one.jsp" />
    <%        }
            else if(n>=1 && n<=50){
    %>             <jsp:forward page="two.jsp">
                    <jsp:param name="number" value="<%= n%>" />
                </jsp:forward>
    <%        }
            else if(n>50 && n<=100){
    %>          <jsp:forward page="three.jsp">
                    <jsp:param name="number" value="<%= n%>" />
                </jsp:forward>
    <%        }
            else{
    %>          <jsp:forward page="error.jsp">
                    <jsp:param name="mess" value="1" />
                </jsp:forward>    
    <%        }
        }catch(Exception e){
    %>      <jsp:forward page="error.jsp">
                <jsp:param name="mess" value="2" />
            </jsp:forward>
    <%    }
    %>

下面是error.jsp的代码以及运行截图
程序代码:
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www. http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>error.jsp</title>
<jsp:include page="head.txt" />
</head>
<body bgcolor="yellow">
    <font size="5" color="red">This is error.jsp</font>    
    <font size="2">
        <%
            String s=request.getParameter("mess");
            out.println("<br />传递过来的错误信息:"+s);
        %>
    </font>
</body>
</html>


搜索更多相关主题的帖子: include yellow PUBLIC method title 
2016-04-28 12:47



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-464222-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.272389 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved