且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Eclipse在jsp中使用Classes

更新时间:2023-01-16 17:14:20

首先不要使用scriptlet来执行任何逻辑
,其次你的代码

First of all dont use scriptlet for any logic to be implemented and secondly your code

<%Hej a = new Hej(); %>

失败,因为您在类中有一个参数化的构造函数,您正在初始化一个没有参数的对象尝试ths

fails because you have a parameterized constructor in your class by you are initializing an object without an argument try ths

<% Hej a = new Hej("Hello World !"); %>

还有一件事,而不是使用默认包创建一些包。

One more thing instead of using default package create some package.

示例创建一个命名为 mypackage 并拖动它里面的类。然后将页面导入更改为如下所示:

Example create a package named mypackage and drag the class inside it. then change the page import to something like this :

<%@ page import="mypackage.Hej" %>