目录
错误: 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).
最好不用这种方法, 先检查代码的单词是否拼写错误;