我是菜鸟…大虾们进来看看吧…

tao1988812 2011-01-13 11:17:10
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<jsp:directive.page import="java.sql.*"/>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>学生录入(CA2004)</title>
<link rel="stylesheet" type="text/css" href="css/green.contents.css">
</head>

<body leftMargin="0" topMargin="0" rightMargin="0" marginwidth="0" marginheight="0">
<form id="CA2004Input">
<table class="outside" cellspacing="0" cellpadding="0" border="0">
<tr id="outside_blk_title">
<td class="side_margin"></td>
<td class="title">
<table width="100%">
<tr>
<td class="formtitle">
学生修改</td>
</td>
<td class="formid">
CA2004
</td>
<td class="formback" >
<input name="back" id="back" type="button" class="button_off" onClick="toBack()"
onMouseOver="this.className='button_on'"
onMouseOut="this.className='button_off'"
value="返回">
</td>
</tr>
</table>
</td>
<td class="side_margin"></td>
</tr>
<tr id="outside_blk_contents">
<td class="side_margin"></td>
<td>
<table class="outline" cellspacing="0" cellpadding="0" width="100%" border="1">
</tr>
<%


ResultSet rs=(ResultSet)request.getAttribute("rs");
while(rs.next()){
%>

<tr class="sheet1">
<td>
<table class="detail" cellpadding="0" cellspacing="2" border="0" width="100%">
<tr>
<td width="10%" class="required">学号</td>
<td width="90%">
<input name="stu_id" type="text" value="<%= rs.getString("STU_ID") %>" class="input_left" size="9" maxlength="6" disabled>
<font color="red" size="-1">* 半角英数,最长6位</font>
</td>
</tr>
<tr>
<td class="required">姓名</td>
<td>
<input name="stu_name" type="text" value="<%=rs.getString("STU_NAME")%>" class="input_left" size="15" maxlength="15">
<font color="red" size="-1">* 最长15位</font>
</td>
</tr>
<tr>
<td class="required">性别</td>
<td>
<%
int i=rs.getInt("STU_SEX");
if(i==1){ %>
<input name="stu_sex" value="1" type="radio" checked>男
<input name="stu_sex" value="2" type="radio" >女

<% }else if(i==2){
%>
<input name="stu_sex" value="1" type="radio" >男
<input name="stu_sex" value="2" type="radio" checked>女
<% }

%>
</td>
</tr>
<tr>
<td class="required">生日</td>
<td>
<input name="stu_birth" type="text" value="<%= rs.getString("STU_BIRTH") %>" class="input_left" size="15">
<font color="red" size="-1">* 格式:YYYY/MM/DD</font>
</td>
</tr>
<tr>
<td class="required">班级</td>
<td>
<select id="stu_class" name="st_class">
<option value="1">计算机1班</option>
<option value="2">计算机2班</option>
<option value="3">计算机3班</option>
<option value="4">计算机4班</option>
</select>
</td>
</tr>
<tr>
<td class="caption">补充说明</td>
<td>
<input type="text" id="stu_remark" class="input_left" size="90" value="" maxlength="50">
</td>
</tr>
<% }

%>
</table>
<tr id="outline_blk_dummy">
<td></td>
</tr>

<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr>
<td width="20%" class="td_center">
<input name="back"
id="back"
type="button"
class="button_off"
onClick="toBack()"
onMouseOver="this.className='button_on'"
onMouseOut="this.className='button_off'"
value="返回"/>
</td>
<td width="30%"></td>
<td width="30%"></td>
<td width="20%" class="td_center">
<input name="input"
id="input"
type="button"
class="button_off"
onClick="input()"
onMouseOver="this.className='button_on'"
onMouseOut="this.className='button_off'"
value="确定"/>
</td>
</tr>
</table>

</td>
</tr>
</table>
</form>

<script language="javascript">

function toBack(){
document.forms[0].action="<%= request.getContextPath() %>/backServlet";
document.forms[0].submit();
}
function input(){
document.forms[0].action="<%= request.getContextPath() %>/inputServlet";
document.forms[0].submit();
}

</script>
</body>
</html>
为什么我点确定他不跳转到我写的那个servlet啊~直接就是没反应~
...全文
132 19 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
tao1988812 2011-01-13
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 mxss343314287 的回复:]

哦 NO! 那不是12楼 13楼 这是14楼
[/Quote]
大哥,你自娱自乐呢…
NickCheng 2011-01-13
  • 打赏
  • 举报
回复
LZ这问题描述的不够清楚,下次提问的时候还是将问题提出来,而不是直接将代码贴出来!
SunfI0wer 2011-01-13
  • 打赏
  • 举报
回复
肯定是你请求的路径错了 你看看你请求的路径对不对 简单方法 一楼兄弟做法
tt986101dpc 2011-01-13
  • 打赏
  • 举报
回复

<base href="<%=basePath%>">

加到<title>前面
tt986101dpc 2011-01-13
  • 打赏
  • 举报
回复
把这句加回去
[code=HTML][
<base href="<%=basePath%>">
/code]

加到<title>前面
fengxuegupo 2011-01-13
  • 打赏
  • 举报
回复
function input(){
alert("ok");
document.forms[0].action="<%= request.getContextPath() %>/inputServlet";
document.forms[0].submit();
}
如果弹出框ok就说明进入这个方法里了,那就是你传参的问题,如果连这个方法都没进,说明你整体有问题

tao1988812 2011-01-13
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 fengxuegupo 的回复:]

首先在JS中alert一下,看有没有调用input这个方法,如果调用了,那就是request.getContextPath这个参数的问题了
[/Quote]
大哥~还请说的详细些吧…怎么alert呀……
tao1988812 2011-01-13
  • 打赏
  • 举报
回复
http://hi.csdn.net/space-7685153-do-album-picid-725862-goto-down.html

我截了图
这是地址 貌似没插上图片~还请各位移驾到这里看看吧……
tao1988812 2011-01-13
  • 打赏
  • 举报
回复


点确定之后ie显示这么句话~
fengxuegupo 2011-01-13
  • 打赏
  • 举报
回复
首先在JS中alert一下,看有没有调用input这个方法,如果调用了,那就是request.getContextPath这个参数的问题了
a21768541 2011-01-13
  • 打赏
  • 举报
回复
首先在servlet里面设个断点,确定是否真的没进入servlet,然后 在检查下路径是否写对了。。
tao1988812 2011-01-13
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 zm851203 的回复:]

在servlet的post方法中加入打印,确定一下
[/Quote]

不打印~貌似就没往servlet跳~
zm_hs 2011-01-13
  • 打赏
  • 举报
回复
在servlet的post方法中加入打印,确定一下
tao1988812 2011-01-13
  • 打赏
  • 举报
回复
谢谢大家了…
tao1988812 2011-01-13
  • 打赏
  • 举报
回复
内牛满面啊…
换个名字就好了…
逍遥庄主 2011-01-13
  • 打赏
  • 举报
回复
<%@ page language="java" pageEncoding="utf-8"%>
<%!
String path=null;
%>
<%
path = request.getContextPath()+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<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">
<script language="JavaScript" type="text/javascript" src="jslib/jquery-1.4.2.js"></script>
<script language="JavaScript" type="text/javascript">
window.onload = function(){
//document.getElementById("txt").value=<%=request.getContextPath()%>+"/inputServlet" 这样报错
document.getElementById("txt").value = <%=path%>+"inputServlet"
}
</script>
</head>
<style>

</style>
<body>
<div>
<input id="txt">
</div>
</body>
</html>

看看这个 也许对你有启发

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧