运行失败:Error during artifact deployment. See server log for details.
老师您好,我在写好代码后进行运行,控制台中出现了如下提示:

我的项目结构:


相关代码:News实体类
package com.lin.ajax.entity;
public class News {
private String title;
private String date;
private String sourse;
private String content;
public News(String title, String date, String sourse, String content) {
this.title = title;
this.date = date;
this.sourse = sourse;
this.content = content;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getSourse() {
return sourse;
}
public void setSourse(String sourse) {
this.sourse = sourse;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}相关代码:
NewsServlet类
package com.lin.ajax.servlet;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.lin.ajax.entity.News;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@WebServlet("/news")
public class NewsServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
List<News> list=new ArrayList<>();
list.add(new News("TIOBE:2018年编程语言排行趋势","2018-5-1","TIOBE","......"));
list.add(new News("TIOBE:2019年编程语言排行趋势","2018-5-1","TIOBE","......"));
list.add(new News("TIOBE:2020年编程语言排行趋势","2018-5-1","TIOBE","......"));
list.add(new News("TIOBE:2012年编程语言排行趋势","2018-5-1","TIOBE","......"));
//这个类是由Json提供的,用来将对象转为Json字符串的
ObjectMapper objectMapper=new ObjectMapper();
String json=objectMapper.writeValueAsString(list);
response.setContentType("text/json;charset=utf-8");
response.getWriter().println(json);
}
}19
收起
正在回答 回答被采纳积分+1
1回答
2023版Java工程师
- 参与学习 人
- 提交作业 8791 份
- 解答问题 9886 个
综合就业常年第一,编程排行常年霸榜,北上广深月薪过万! 不需要基础,无需脱产即可学习,只要你有梦想,想高薪! 全新升级:技术栈升级(包含VUE3.0,ES6,Git)+项目升级(前后端联调与功能升级)
了解课程



恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星