web交互性与调试

目录

web交互性

web调试

错误:   Undefined attribute name ()


web交互性

交互性是web开发的核心逻辑, 对于web开发交互性的体现在表单上, 也就是说"<form>"元素中有一个action的路径, 这个路径就表示将表单数据提交的动态页面. 而动态页面接收这个提交的数据,则应该使用固定的方法: request.getParameter("name参数名称"), 该方法返回的是String型的数据. 

范例: 建立input.html 文件

<html>
<head>
<title>Input Data</title>
<meta charset="UTF-8">
</head>
<body>
<form action="input_do.jsp" method="post">
	请输入信息:<input type="text" id="msg" name="msg">
	<input type="submit" value="提交">
</form>
</body>
</html>

表单中的元素id是留给脚本语言操作页面使用的, 而name是留给JSP接收参数使用(request.getParameter("name")) ;

范例: 建立show.jsp页面

<html>
<head>
<title>Insert title here</title>
</head>
<body>
<%	// 接收用户发送来的请求信息, 其中msg是发送表单的input组件的name属性定义
	String inputMsg = request.getParameter("msg") ;
	out.println("[SECHO]" + inputMsg);
%>
</body>
</html>

接收的参数返回的是字符串,可以使用正则验证, 可以变为各种数据类型, 可以使用String类的一系列操作进行字符串处理.

web调试

如果使用eclipse调试JSP页面, 需要保证是在Eclipse之中debug 启动Tomcat. 

范例: 调试input_do.jsp页面

<html>
<head>
<title>Insert title here</title>
</head>
<body>
<%	
	 String inputMsg = null ;
	 inputMsg = request.getParameter("msg") ;
	 if ( inputMsg == null || "".equals(inputMsg)) {
		 out.println(" ************ ERROR *************");
	 } else {
		out.println("[SECHO]" + inputMsg);
	 }
%>
</body>
</html>

 

 

 

错误:   Undefined attribute name ()

Multiple annotations found at this line:
    - Undefined attribute name (action).
    - <from action="input_do.jsp" method="post">
    - Undefined attribute name (method).
    - Unknown tag (from).

最好不用这种方法,  先检查代码的单词是否拼写错误;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值