我有一个简单的 html 表单(名字和姓氏),一旦我点击提交,它应该给我一个来 self 的 java servlet 的简单响应,上面写着“你好,名字和姓氏”
我使用 eclipse 和 tomcat 插件运行它,它运行得很好..但是当我创建一个 war 文件并从 tomcat 部署它时..我得到第一个屏幕..输入名字和姓氏..但是当我点击提交,它会在我的代码中寻找“WelcomeScreen” 我有“welcomeScreen”吗?下面是我的 HTML 代码。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Please enter your name</title>
</head>
<body>
<form name="input" action=Hello method="get">
First name: <input type="text" name="firstname"><br> Last
name: <input type="text" name="lastname"> <input type="submit"
value="Submit">
</form>
</body>
</html>
最佳答案
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Please enter your name</title>
</head>
<body>
<form name="input" action="Hello.html" method="get">
First name: <input type="text" name="firstname" /><br>
Last name: <input type="text" name="lastname" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
我写了正确的代码。 html中有一些错误;
<form name="input" action=Hello method="get">
<!-- You've forgotten quotes -->
<!-- And also dont forget to write ".html" or Hello controller in framework like MVC -->
<form name="input" action="Hello.html" method="get">
另一个
<input type="text" name="firstname">
<!-- You've forgotten /// -->
<input type="text" name="firstname" />
还有你的 Hello.html
<html>
<head>
<title>Title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<script type="text/javascript">
var get = window.location.search.replace( "?", "" );
alert(get);
</script>
</head>
<body>
<div>Content</div>
</body>
</html>
关于java - 简单的 html 表单 .. 未执行操作字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20959453/