0

I am working on a project that runs a java back-end and has a web page UI.Basically, the java system runs in on the server and keeps a log of rules that are created in the web page. What I need it to do is take inputs from the text fields on the web page and call a function to pass them to the java object to create a new rule. I also need to be able to call a function to return an array of the rule objects I have created so I can build a table of them on the web page.

I have the UI built as a JSP page and the back-end java classes and functions are all built but I am lost as to how to connect the two.

This is my first attempt at creating a system like this and I have never written anything with Java EE or JSP before.

What I was thinking I could do would be to call a java function when I click the "submit" button to add a new rule and pass the field values to it. I had the same feeling for when I click a button to display the current rules, calling a java function to get the array of objects back and build it into a table.

Does anyone have any insight onto this?

Thanks!

4

2 回答 2

0

我希望您想知道您是否可以在 JSP 中创建后端 Java 类的对象并调用这些对象的函数。为此,您可以使用:

脚本标签 <% any java code in between%>

<% A a=new A();
a.funtion_of_class_A();%>

要显示内容,您可以使用表达式标签。

<%=a.someotherfuntion()%>

您可以使用指令来导入、初始化和定义变量

<%@ page import="com.a" %>
于 2012-10-26T15:48:07.153 回答
0

正如戴夫牛顿所说,有多种方法可以解决这个问题。最简单的一种是使用 Web 框架。你可以谷歌Java Web Framework或阅读这篇文章

如果您正在寻找可与 JSP 一起使用的、轻量级且非常易于使用的东西,我会选择Stripes

于 2012-10-26T15:06:51.037 回答