【发布时间】:2018-11-03 05:19:09
【问题描述】:
应用程序欢迎页面正在运行,但是当我单击超链接时,它显示错误:
类型状态:报告
消息:/Welcome/nextPage
描述:源服务器没有找到当前的表示 对于目标资源还是不愿意
我猜这与 web.xml 文件有关。我的尝试之一是编写以下内容:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
<display-name>MyApp</display-name>
<welcome-file-list>
<welcome-file>WelcomeServlet</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>NextPageServlent</servlet-name>
<jsp-file>/NextPageServlent/nextPage.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>NextPageServlent</servlet-name>
<url-pattern>/NextPageServlent/*</url-pattern>
</servlet-mapping>
</web-app>
不过没用,我也有同样的问题
编辑: 指向“下一页”的超链接
index.jsp:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%
String table=(String) request.getAttribute("table");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>table content</title>
</head>
<body>
<h1>table content</h1>
<p>
<a href="nextPage">go to the next page </a>
</p>
<%= table %>
</body>
</html>
网页链接:http://localhost:8080/Welcome/nextPage
有没有办法不使用web.xml文件?
【问题讨论】:
-
点击了什么超链接?
-
点击下一个页面...假设显示下一个页面
-
主页是如何生成的?超链接是什么样的?这里缺少太多信息和细节。
-
生成的主页:index.jsp、WelcomeServlet.java、ReadQuery.java .....超链接(在 nextPage.jsp 中):查看股票' 状态变化
-
将
index.jsp添加到您的问题中。另外,打开浏览器,导航到主页,右键单击链接并将 URL 复制到您的问题,以便我们查看实际发生的情况。
标签: java xml jsp web-applications