为什么找不到源文件?
package com.imooc.servlet.chaxun;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
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 javax.servlet.http.HttpSession;
/**
* Servlet implementation class ChaXun
*/
@WebServlet("/ServletChaXun")
public class ChaXun extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public ChaXun() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Map<String,String> wordMap=new HashMap<>();
wordMap.put("apple", "苹果");
wordMap.put("pear","梨");
wordMap.put("watermelon","西瓜");
String k=request.getParameter("search");
Boolean flag=false;
String result=null;
if(wordMap.containsKey(k)) {
flag=true;
result=wordMap.get(k);
}else {
result="没有找到对应的单词解释";
}
if(flag) {
request.setAttribute("result", result);
request.getRequestDispatcher("/success.jsp").forward(request, response);
}else {
HttpSession hs=request.getSession();
hs.setAttribute("result", result);
response.sendRedirect("/LianXiTi/false.jsp");
}
}
}<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <form action="/LianXiTi/ServletChaXun"> <input name="serach" placeholder="请输入要查询的单词"> <input type="submit" value="查询"> </form> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<p style="color:blue;font-size:30px;font-weight:bload;">
<%=(String)request.getAttribute("result") %>
</p>
</body>
</html><%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<p style="color:red;font-size:30px;font-weight:bload;">
<%=(String)session.getAttribute("result") %>
</p>
</body>
</html>为什么在浏览器中输入地址出现404错误?
1
收起
正在回答 回答被采纳积分+1
2回答
慕田峪1061482
2019-09-24 14:09:34
2. 从网页搭建入门JavaWeb
- 参与学习 人
- 提交作业 676 份
- 解答问题 9666 个
本阶段将从前端网页搭建入手,到Java Web基础,前后端结合助你完成Java Web小白的蜕变!
了解课程



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