java页面跳转t赋值_Java web:JSP地址栏传参,页面跳转,表单提交,日期脚本文件,日期框【诗书画唱】...

1、创建一个新增商品的pro.jsp页面,要求能够输入商品名称,价格和进货日期,提交到doAdd.jsp页面,将输入的商品名称,价格以及进货日期打印出来。提交这个表单时还需要额外的提交一个属性addr=china,请设计一种方案将addr的值也提交到doAdd.jsp页面

【个人的思路:

用上地址栏传参,就是

String addr = request.getParameter("addr");

System.out.println(addr);】

a5369e1069fb12df430a12c48a9c9895.png

52ed2ead636b1762d91ba6798ccb0ee7.png

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

11dcee5f1a5bf3cd3e3cfa253d5b903b.png

1223e62bcd5d2e68189dd9c9a8d51420.png

商品名称:
商品价格:
进货日期:

readonly οnclick="new Calendar().show(this);" />

e12eab42af35de43e1018b9231e44747.png

5aeba48c2d025e2ab4921ff79b10c7b9.png

pageEncoding="UTF-8"%>

String path = request.getContextPath();

String basePath = request.getScheme()+"://"

+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

675ca3e6e1a501387bc047e7cd8cb664.png

诗书画唱提醒你!跟我学JSP行为!

content="This is my page">

//下面是用request处理中文乱码:

request.setCharacterEncoding("utf-8");

String spName= request.getParameter("spName");

System.out.println("商品名称:"+spName);

String spPrice= request.getParameter("spPrice");

System.out.println("商品价格:"+spPrice);

/**值得注意的是这里要把String类型转换成Double类型等,因为在自己写的

shangPin类中,Price为Double类型,在用下面的

JSP动作指令插入Double类型内容中时,不这样的话,就会报错等

*/

Double spPriceDouble=Double.valueOf(spPrice);

//__________

String birthday= request.getParameter("birthday");

System.out.println("生产日期:"+birthday);

String addr = request.getParameter("addr");

System.out.println(addr);

%>

value=""/>

value=""/>

商品名称:   

商品单价:     元/件

商品生产日期:       

商品生产地址:   

7ab4f6e671d126bdc03e69f298aabac7.png

eb569d4d81272a6683280e6cef75bfe2.png

package com.SSHC;

import java.util.Date;

public class ShangPin {

private String  bianHao;

private String  name;

private Double  price;

private String   birthday;

public String getBianHao() {

return bianHao;

}

public String getBirthday() {

return birthday;

}

public void setBirthday(String birthday) {

this.birthday = birthday;

}

public void setBianHao(String bianHao) {

this.bianHao = bianHao;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public Double getPrice() {

return price;

}

public void setPrice(Double price) {

this.price = price;

}

}

2c3839db5ac2e3e3f392b1302a52c2fa.png

5679095943cc8638ba9c22810258725f.png不一定要用这个,自己网上找到后用

/**

* Calendar

* @param   beginYear           1990

* @param   endYear             2010

* @param   language            0(zh_cn)|1(en_us)|2(en_en)|3(zh_tw)

* @param   patternDelimiter    "-"

* @param   date2StringPattern  "yyyy-MM-dd"

* @param   string2DatePattern  "ymd"

* @version 1.0 build 2006-04-01

* @version 1.1 build 2006-12-17

* @author  KimSoft (jinqinghua [at] gmail.com)

* NOTE!    you can use it free, but keep the copyright please

* IMPORTANT:you must include this script file inner html body elment

*/

function Calendar(beginYear, endYear, language, patternDelimiter, date2StringPattern, string2DatePattern) {

this.beginYear = beginYear || 1978;

this.endYear   = endYear   || 2020;

this.language  = language  || 0;

this.patternDelimiter = patternDelimiter     || "-";

this.date2StringPattern = date2StringPattern || Calendar.language["date2StringPattern"][this.language].replace(/\-/g, this.patternDelimiter);

this.string2DatePattern = string2DatePattern || Calendar.language["string2DatePattern"][this.language];

this.dateControl = null;

this.panel  = this.getElementById("__calendarPanel");

this.iframe = window.frames["__calendarIframe"];

this.form   = null;

this.date = new Date();

this.year = this.date.getFullYear();

this.month = this.date.getMonth();

this.colors = {"bg_cur_day":"#00CC33","bg_over":"#EFEFEF","bg_out":"#FFCC00"}

};

Calendar.language = {

"year"   : ["\u5e74", "", "", "\u5e74"],

"months" : [

["\u4e00\u6708","\u4e8c\u6708","\u4e09\u6708","\u56db\u6708","\u4e94\u6708","\u516d\u6708","\u4e03\u6708","\u516b\u6708","\u4e5d\u6708","\u5341\u6708","\u5341\u4e00\u6708","\u5341\u4e8c\u6708"],

["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"],

["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"],

["\u4e00\u6708","\u4e8c\u6708","\u4e09\u6708","\u56db\u6708","\u4e94\u6708","\u516d\u6708","\u4e03\u6708","\u516b\u6708","\u4e5d\u6708","\u5341\u6708","\u5341\u4e00\u6708","\u5341\u4e8c\u6708"]

],

"weeks"  : [["\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d"],

["Sun","Mon","Tur","Wed","Thu","Fri","Sat"],

["Sun","Mon","Tur","Wed","Thu","Fri","Sat"],

["\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d"]

],

"clear"  : ["\u6e05\u7a7a", "Clear", "Clear", "\u6e05\u7a7a"],

"today"  : ["\u4eca\u5929", "Today", "Today", "\u4eca\u5929"],

"close"  : ["\u5173\u95ed", "Close", "Close", "\u95dc\u9589"],

"date2StringPattern" : ["yyyy-MM-dd", "yyyy-MM-dd", "yyyy-MM-dd", "yyyy-MM-dd"],

"string2DatePattern" : ["ymd","ymd", "ymd", "ymd"]

};

Calendar.prototype.draw = function() {

calendar = this;

var _cs = [];

_cs[_cs.length] = '

';

_cs[_cs.length] = '

_cs[_cs.length] = '

';

_cs[_cs.length] = ' 

';

_cs[_cs.length] = ' 

';

_cs[_cs.length] = ' 

';

_cs[_cs.length] = ' ';

_cs[_cs.length] = '

';

for(var i = 0; i < 7; i++) {

_cs[_cs.length] = '

';

_cs[_cs.length] = Calendar.language["weeks"][this.language][i];

_cs[_cs.length] = '';

}

_cs[_cs.length] = '';

for(var i = 0; i < 6; i++){

_cs[_cs.length] = '

';

for(var j = 0; j < 7; j++) {

switch (j) {

case 0: _cs[_cs.length] = '

 '; break;

case 6: _cs[_cs.length] = '

 '; break;

default:_cs[_cs.length] = '

 '; break;

}

}

_cs[_cs.length] = '';

}

_cs[_cs.length] = '

';

_cs[_cs.length] = ' 

';

_cs[_cs.length] = ' 

';

_cs[_cs.length] = ' 

';

_cs[_cs.length] = ' ';

_cs[_cs.length] = '';

_cs[_cs.length] = '';

this.iframe.document.body.innerHTML = _cs.join("");

this.form = this.iframe.document.forms["__calendarForm"];

this.form.clearButton.value = Calendar.language["clear"][this.language];

this.form.selectTodayButton.value = Calendar.language["today"][this.language];

this.form.closeButton.value = Calendar.language["close"][this.language];

this.form.goPrevMonthButton.onclick = function () {calendar.goPrevMonth(this);}

this.form.goNextMonthButton.onclick = function () {calendar.goNextMonth(this);}

this.form.yearSelect.onchange = function () {calendar.update(this);}

this.form.monthSelect.onchange = function () {calendar.update(this);}

this.form.clearButton.onclick = function () {calendar.dateControl.value = "";calendar.hide();}

this.form.closeButton.onclick = function () {calendar.hide();}

this.form.selectTodayButton.onclick = function () {

var today = new Date();

calendar.date = today;

calendar.year = today.getFullYear();

calendar.month = today.getMonth();

calendar.dateControl.value = today.format(calendar.date2StringPattern);

calendar.hide();

}

};

Calendar.prototype.bindYear = function() {

var ys = this.form.yearSelect;

ys.length = 0;

for (var i = this.beginYear; i <= this.endYear; i++){

ys.options[ys.length] = new Option(i + Calendar.language["year"][this.language], i);

}

};

Calendar.prototype.bindMonth = function() {

var ms = this.form.monthSelect;

ms.length = 0;

for (var i = 0; i < 12; i++){

ms.options[ms.length] = new Option(Calendar.language["months"][this.language][i], i);

}

};

Calendar.prototype.goPrevMonth = function(e){

if (this.year == this.beginYear && this.month == 0){return;}

this.month--;

if (this.month == -1) {

this.year--;

this.month = 11;

}

this.date = new Date(this.year, this.month, 1);

this.changeSelect();

this.bindData();

};

Calendar.prototype.goNextMonth = function(e){

if (this.year == this.endYear && this.month == 11){return;}

this.month++;

if (this.month == 12) {

this.year++;

this.month = 0;

}

this.date = new Date(this.year, this.month, 1);

this.changeSelect();

this.bindData();

};

Calendar.prototype.changeSelect = function() {

var ys = this.form.yearSelect;

var ms = this.form.monthSelect;

for (var i= 0; i < ys.length; i++){

if (ys.options[i].value == this.date.getFullYear()){

ys[i].selected = true;

break;

}

}

for (var i= 0; i < ms.length; i++){

if (ms.options[i].value == this.date.getMonth()){

ms[i].selected = true;

break;

}

}

};

Calendar.prototype.update = function (e){

this.year  = e.form.yearSelect.options[e.form.yearSelect.selectedIndex].value;

this.month = e.form.monthSelect.options[e.form.monthSelect.selectedIndex].value;

this.date = new Date(this.year, this.month, 1);

this.changeSelect();

this.bindData();

};

Calendar.prototype.bindData = function () {

var calendar = this;

var dateArray = this.getMonthViewDateArray(this.date.getFullYear(), this.date.getMonth());

var tds = this.getElementsByTagName("td", this.getElementById("__calendarTable", this.iframe.document));

for(var i = 0; i < tds.length; i++) {

tds[i].style.backgroundColor = calendar.colors["bg_over"];

tds[i].onclick = null;

tds[i].onmouseover = null;

tds[i].onmouseout = null;

tds[i].innerHTML = dateArray[i] || " ";

if (i > dateArray.length - 1) continue;

if (dateArray[i]){

tds[i].onclick = function () {

if (calendar.dateControl){

calendar.dateControl.value = new Date(calendar.date.getFullYear(),

calendar.date.getMonth(),

this.innerHTML).format(calendar.date2StringPattern);

}

calendar.hide();

}

tds[i].onmouseover = function () {this.style.backgroundColor = calendar.colors["bg_out"];}

tds[i].onmouseout  = function () {this.style.backgroundColor = calendar.colors["bg_over"];}

var today = new Date();

if (today.getFullYear() == calendar.date.getFullYear()) {

if (today.getMonth() == calendar.date.getMonth()) {

if (today.getDate() == dateArray[i]) {

tds[i].style.backgroundColor = calendar.colors["bg_cur_day"];

tds[i].onmouseover = function () {this.style.backgroundColor = calendar.colors["bg_out"];}

tds[i].onmouseout  = function () {this.style.backgroundColor = calendar.colors["bg_cur_day"];}

}

}

}

}//end if

}//end for

};

Calendar.prototype.getMonthViewDateArray = function (y, m) {

var dateArray = new Array(42);

var dayOfFirstDate = new Date(y, m, 1).getDay();

var dateCountOfMonth = new Date(y, m + 1, 0).getDate();

for (var i = 0; i < dateCountOfMonth; i++) {

dateArray[i + dayOfFirstDate] = i + 1;

}

return dateArray;

};

Calendar.prototype.show = function (dateControl, popuControl) {

if (this.panel.style.visibility == "visible") {

this.panel.style.visibility = "hidden";

}

if (!dateControl){

throw new Error("arguments[0] is necessary!")

}

this.dateControl = dateControl;

popuControl = popuControl || dateControl;

this.draw();

this.bindYear();

this.bindMonth();

if (dateControl.value.length > 0){

this.date  = new Date(dateControl.value.toDate(this.patternDelimiter, this.string2DatePattern));

this.year  = this.date.getFullYear();

this.month = this.date.getMonth();

}

this.changeSelect();

this.bindData();

var xy = this.getAbsPoint(popuControl);

this.panel.style.left = xy.x + "px";

this.panel.style.top = (xy.y + dateControl.offsetHeight) + "px";

this.panel.style.visibility = "visible";

};

Calendar.prototype.hide = function() {

this.panel.style.visibility = "hidden";

};

Calendar.prototype.getElementById = function(id, object){

object = object || document;

return document.getElementById ? object.getElementById(id) : document.all(id);

};

Calendar.prototype.getElementsByTagName = function(tagName, object){

object = object || document;

return document.getElementsByTagName ? object.getElementsByTagName(tagName) : document.all.tags(tagName);

};

Calendar.prototype.getAbsPoint = function (e){

var x = e.offsetLeft;

var y = e.offsetTop;

while(e = e.offsetParent){

x += e.offsetLeft;

y += e.offsetTop;

}

return {"x": x, "y": y};

};

/**

* @param   d the delimiter

* @param   p the pattern of your date

* @author  meizz

* @author  kimsoft add w+ pattern

*/

Date.prototype.format = function(style) {

var o = {

"M+" : this.getMonth() + 1, //month

"d+" : this.getDate(),      //day

"h+" : this.getHours(),     //hour

"m+" : this.getMinutes(),   //minute

"s+" : this.getSeconds(),   //second

"w+" : "\u65e5\u4e00\u4e8c\u4e09\u56db\u4e94\u516d".charAt(this.getDay()),   //week

"q+" : Math.floor((this.getMonth() + 3) / 3),  //quarter

"S"  : this.getMilliseconds() //millisecond

}

if (/(y+)/.test(style)) {

style = style.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));

}

for(var k in o){

if (new RegExp("("+ k +")").test(style)){

style = style.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));

}

}

return style;

};

/**

* @param d the delimiter

* @param p the pattern of your date

* @rebuilder kimsoft

* @version build 2006.12.15

*/

String.prototype.toDate = function(delimiter, pattern) {

delimiter = delimiter || "-";

pattern = pattern || "ymd";

var a = this.split(delimiter);

var y = parseInt(a[pattern.indexOf("y")], 10);

//remember to change this next century ;)

if(y.toString().length <= 2) y += 2000;

if(isNaN(y)) y = new Date().getFullYear();

var m = parseInt(a[pattern.indexOf("m")], 10) - 1;

var d = parseInt(a[pattern.indexOf("d")], 10);

if(isNaN(d)) d = 1;

return new Date(y, m, d);

};

document.writeln('

');

document.writeln('');

var __ci = window.frames['__calendarIframe'];

__ci.document.writeln('/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN" "http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd">');

__ci.document.writeln('');

__ci.document.writeln('

');

__ci.document.writeln('');

__ci.document.writeln('

Web Calendar(UTF-8) Written By KimSoft');

__ci.document.writeln('

__ci.document.writeln('');

__ci.document.writeln('<\/style>');

__ci.document.writeln('<\/head>');

__ci.document.writeln('

');

__ci.document.writeln('<\/body>');

__ci.document.writeln('<\/html>');

__ci.document.close();

document.writeln('<\/div>');

var calendar = new Calendar();

5706308412de146408e704d60c838643cddf1557.png

0ba15d973aec8461efc1775eca8ebb7a6ac6f5e3.png

e198f5afd775e4c4c60b33c32136aea19c13440c.png

2、在浏览器地址栏输入http://localhost:8080/J190801/test.jsp?act=admin&pwd=123&type=user,请将路径中的act、pwd以及user对应的值在test.jsp页面中显示出来(注意不是后台打印,是在页面上显示)b7d2ac069aa039f4c931fc4ae0809a9a7b5826ba.png

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

b6b9fe48961bbeae1eb7ef048710b3fffc784c8f.png

"keyword1,keyword2,keyword3">

* {

font-size: 50px;

}

//注册按钮的功能:跳转到注册页面

function toReg(){

window.location.href = 'test.jsp?act=admin&pwd=123&type=user';

}

method="post">

οnclick="toReg();" />

23a5d41875bdf116ec7ef9b06e0fce98.png

ea3965296bab251dc983cf23ff2baddf.png

pageEncoding="UTF-8"%>

String path = request.getContextPath();

String basePath = request.getScheme()+"://"

+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

ed0fa4322d83fe1891af9a29321b5df8.png

诗书画唱提醒你!跟我学JSP行为!

content="This is my page">

//下面是用request处理中文乱码:

request.setCharacterEncoding("utf-8");

String act= request.getParameter("act");

System.out.println("用户名:"+act);

String pwd= request.getParameter("pwd");

System.out.println("用户密码:"+pwd);

String type= request.getParameter("type");

System.out.println("用户类型:"+type);

%>

用户名:   

用户密码:   

用户类型:

27704523b1ccc63f1e75d7e3906367f5.png

f7053401cb09be619e3eaa5f648d536e.png

a6102488d4543b4c18d6dacbf583ae2f.png

3682d6ecac6828a320e9bd361fb65985.png

725445667f9e4e6a886cf47be7a64770.png

c4326b8c69875120eab06602694539f6.png

9ea5756bd0ba4ab0424365e6ce34802c.png

6b30df0b39d7b07858dd30f4d63f9499.png

5038f45222e63718329f0ead8519fc7d.png

752702d3dfb7f1fc09f2b2ec47ef727b.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值