JSP跳转到Servlet出现404错误

PLATINUM_II Java开发工程师  2017-11-01 05:36:00
JSP:

<div class="fbneirong">
<form class="am-form" action="ChangeBookServlet"method="post" >
<div class="am-form-group am-cf">
<div class="zuo">编号:</div>
<div class="you">
<input type="text" class="am-input-sm" id="doc-ipt-pwd-1" name="book_id" placeholder="${bookList[0].book_id}" readonly="readonly">
</div>
</div>


Servlet:


package com.servlet;

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;

import com.bean.Book;
import com.dao.BookDao;

/**
* Servlet implementation class ChangeBookServlet
*/
@WebServlet("/ChangeBookServlet")
public class [color=#FFCC00]ChangeBookServlet[/color] extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public ChangeBookServlet() {
super();
// TODO Auto-generated constructor stub
}

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doPost(request, response);
}

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");

String id = request.getParameter("book_id");
int book_id = Integer.parseInt(id);
System.out.println(book_id);
String book_name = request.getParameter("book_name");
String book_writer = request.getParameter("book_writer");
float book_price = Float.parseFloat(request.getParameter("book_price"));
String book_img = request.getParameter("book_img");
Book book = new Book(book_id, book_name, book_writer, book_price, book_img);
BookDao.updateBook(book);
}

}


在jsp的action中加了/也不行,写全路径也不行。web.xml中什么都没写,但是添加删除查找都可以,就是这个Servlet跳转不到。
...全文
75 3 点赞 打赏 收藏 举报
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
PLATINUM_II 2017-11-02
重启电脑后404变为500,原因是 placeholder不是默认参数,servlet获取不到值,将 placeholder改为value就好了。
  • 打赏
  • 举报
回复
PLATINUM_II 2017-11-01
我把Servlet换成其他的都可以跳转,就是这个不行。
  • 打赏
  • 举报
回复
PLATINUM_II 2017-11-01
  • 打赏
  • 举报
回复
相关推荐
发帖
Java EE
加入

6.7w+

社区成员

J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
申请成为版主
帖子事件
创建了帖子
2017-11-01 05:36
社区公告
暂无公告