程序代码:
servlet文件代码:
package com.blog;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/blogservlet")
public class blogservlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public blogservlet() {
super();}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
String title = request.getParameter("title");
String content = request.getParameter("content");
String categoryId = request.getParameter("category");
System.out.println(title);
System.out.println(content);
System.out.println(categoryId);
}
}
web.xml我没有进行配置,因为在网上搜了下servlet 3.0好像不需要手动配置
一晚上都被这个问题卡住,求解决方法
附图n张
web.xml未改动如下
<?xml version="1.0" encoding="UTF-8"?>
blog
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp