JSp小程序编写

JSp小程序编写,第1张

你好,两个jsp文件,test02.jsp,test03.jsp.代码如下:

<%@ page contentType="text/htmlcharset=gb2312" %>

<%

String num = (String)request.getParameter("num")

try{

int n = Integer.parseInt(num)

if(n%2==0)

request.setAttribute("type","偶数")

else

request.setAttribute("type","奇数")

request.getRequestDispatcher("test03.jsp").forward(request,response)

}catch(Exception e){

e.printStackTrace()

}

%>

<%@ page contentType="text/htmlcharset=gb2312" %>

<% String type = (String)request.getAttribute("type")%>

<html>

<head><title>页面一</title></head>

<body>

<form action="test02.jsp" method="get">

请输入一个数字:<input type="text" name="num" />

<input type="submit" value="提交" />

</form>

${type }

</body>

</html>

<html>

<head>

<title>My JSP 'exam.jsp' starting page</title>

<script type="text/javascript" >

function loop(){

// var shu=parseInt(document.form1.number.value)

var count=0

var result=""

var i=1

for(i<=100i++)

{

if(i%7===0||(i.toString().indexOf("7"))!=-1)

result+="第"+(++count)+"个数为:"+i+"<br>"

}

outR.innerHTML=result

}

</script>

</head>

<body onLoad="loop()">

<div id="outR">

</div>

</body>

</html>

求分。。。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/12047451.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-20
下一篇2023-05-20

发表评论

登录后才能评论

评论列表(0条)

    保存