Servlet 的参数传递问题
我使用 NetBeans 6.9 创建了一个 Web 应用程序项目和 Java 应用程序项目。现在,我的项目结构就像,
Web Application Project
WEB-INF
JSP Page
Source Package
Servlet
Java Application Project
default package
Java File
现在,我想将参数从 Servlet/JSP 传递到 Java 文件(双向)。谁能帮助我,我该如何解决这个问题?提前致谢。
I have created a Web Application Project and Java Application Project using NetBeans 6.9. Now, my project structure is like,
Web Application Project
WEB-INF
JSP Page
Source Package
Servlet
Java Application Project
default package
Java File
Now, I want to pass parameters from Servlet/JSP to Java file (in both direction). Can anybody help me, how can I solve this ? Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
传递到 JSP/Servlet 的参数很可能通过请求参数(或者可能是会话参数)完成。这是在构造查询字符串时完成的。
例如;
在 Servlet 的情况下可以使用相同的查询字符串。 Servlet 只需要在 web.xml 中进行配置即可,这是通过
web.xml 中的
和
标记。JSP 和 Servlet 文件都应该能够导入和引用您提到的默认包下的“Java 文件”的方法。假设 Java 文件位于类路径上(作为类文件或 JAR 文件),则可以直接调用类中的方法。
查看一些有关开发网络应用程序的介绍性教程,您很快就会获得一些有关这一切如何工作的示例。
Your parameter passing to the JSP/Servlet will most likely be done via request parameters (or possibly session parameters. This is done in the construction of your query string.
For example;
The same query strings can be used in the case of Servlets. The Servlets simply need to be configured in your web.xml This is done via the
<servlet>
and<servlet-mapping>
tags within the web.xml.Both the JSP and Servlet files should be able to import and reference the methods of your "Java File" under the default pacakage that you mentioned. The can directly call methods in your classes assuming that the Java file is on your classpath (either as a class file or in a JAR file).
Take a look at some introductory tutorials on developing a web-app and you'll soon get some examples of how this all works.