使用JSP获取文本框值 [英] Getting textbox values using JSP
问题描述
我是使用JSP的新手,我需要在单击按钮时从文本框中获取值。我正在使用Java Netbeans与服务器apache tomcat。这是它的工作原理...
I'm new in using JSP and I need to get a value from a textbox by upon clicking a button. I am using Java Netbeans with the server apache tomcat. This is how it works...
文本框包含在HTML标记< table>
中用户输入一个值,他点击按钮然后会出现一个消息框,其中包含他输入的值。
The textbox is enclosed in an HTML tag <table>
once the user inputs a value, he clicks the button then a message box will appear with the value he entered.
我不熟悉JSP,它给我带来了困难。
I am not familiar with JSP and it gives me a hard time.
推荐答案
我的回答非常熟悉第一个答案。
My answer is quite familiar with the first answer.
mainPage.jsp
mainPage.jsp
<html>
<head>
<title>Your Title Here</title>
</head>
<body>
<form action="sample.jsp" method="POST">
<input type="text" id="firstname" name="firstname" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
sample.jsp
sample.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%
String firstname = request.getParameter("firstname");
/*
* Some code here
*/
%>
我也在使用apache tomcat。
I'm also using apache tomcat.
您必须按照第一个答案中的说明配置您的web.xml。
You have to configure your web.xml as said in the first answer.
希望有所帮助。
这篇关于使用JSP获取文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!