0
我想将一个字符串传递给一个jsp文件,然后我希望这个jsp文件会对这个字符串做些什么。我不知道jsp。我只是想确保我的逻辑是正确的。我的代码“有效”,但我想确定它的功能。我想我发布字符串的val到浏览器的内存并调用test.jsp文件。那是怎么回事?或者我应该做一些完全不同的事情?从html文件传递字符串变量到JSP
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(document).ready(function(){
var qString = '';
$('#execute').click(function(){
qString = $('#query-string').val();
console.log(qString);
$.post('test.jsp',qString);
});
});
</script>
</head>
<body>
<section>
<label for="query-string">Enter your query here!</label>
<input type="text" id="query-string">
<button id="execute">Execute</button>
</section>
</body>
</html>