gpt4 book ai didi

java - 生成的 servlet 错误 : source value 1. 5 已过时,将在未来版本中删除使用 Jsp 错误

转载 作者:行者123 更新时间:2023-12-01 22:03:50 25 4
gpt4 key购买 nike

当我将表数据发送到jsp页面以及ajax调用数据发送成功时。但 jsp 页面我收到此错误。我不知道如何修复错误。我附上了错误和代码如下

org.apache.jasper.JasperException:PWC6033:JSP 的 Javac 编译出错

PWC6199: Generated servlet error:
source value 1.5 is obsolete and will be removed in a future release

PWC6199: Generated servlet error:
target value 1.5 is obsolete and will be removed in a future release

PWC6199: Generated servlet error:
To suppress warnings about obsolete options, use -Xlint:-options.

PWC6197: An error occurred at line: 17 in the jsp file: /sales_add.jsp
PWC6199: Generated servlet error:
cannot find symbol
symbol: class product
location: class org.apache.jsp.sales_005fadd_jsp

PWC6197: An error occurred at line: 17 in the jsp file: /sales_add.jsp
PWC6199: Generated servlet error:
cannot find symbol
symbol: class product
location: class org.apache.jsp.sales_005fadd_jsp

PWC6197: An error occurred at line: 17 in the jsp file: /sales_add.jsp
PWC6199: Generated servlet error:
cannot find symbol
symbol: class product
location: class org.apache.jsp.sales_005fadd_jsp

PWC6197: An error occurred at line: 17 in the jsp file: /sales_add.jsp
PWC6199: Generated servlet error:
cannot find symbol
symbol: class product
location: class org.apache.jsp.sales_005fadd_jsp

Jsp页面

<%  

String jsonData = request.getParameter("data");
Gson gson = new Gson();
product data1 = gson.fromJson(jsonData, product.class);
String item = data1.getItem();
int price = data1.getPrice();
int qty = data1.getQty();
int total = data1.getTotal();


product user = new product();
user.setItem(item);
user.setItem(price);
user.setItem(qty);
user.setItem(total);


String jsonObj = gson.toJson(user);
out.print(jsonObj);

%>

最佳答案

此消息:

> PWC6199: Generated servlet error:
> source value 1.5 is obsolete and will be removed in a future release

可能意味着您的 Web 容器尚未配置用于生成代码的 Java 版本,并且假设为 Java 5。请检查 Web 容器配置。

解决方案:检查Web容器文档。或者忽略该消息。 (这是警告而不是错误。)

其他错误是由于 JSP 中缺少导入造成的。您尝试使用名为 product 的类,但 Java 编译器找不到它。

解决方案:在页面开头添加导入。语法是

<%@ page import="java.util.List" %>

...并且您需要为您的类使用正确的完全限定名称。

(您也可能拼错了名称。风格正确的类名称将是 Product。)

<小时/>

其他评论:

  • 如果您的类名确实称为product,请修复它。这是一个重大的风格错误。它应该是产品
  • 正如 @Scary Wombat 指出的那样,您不应该将 JSP 用于任意 Java 代码。使用 JSTL 编写逻辑(在本例中不实用),使用 Servlet 实现,或者使用 Spring Boot/Spring MVC 或类似技术。将任意 Java 代码放入 JSP 中会带来各种技术和可维护性问题。

    JSP 应该只真正用于将 Servlet 的结果呈现为 HTML 输出。它们不应包含业务逻辑,

关于java - 生成的 servlet 错误 : source value 1. 5 已过时,将在未来版本中删除使用 Jsp 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58704693/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com