【发布时间】:2017-04-22 10:41:21
【问题描述】:
我的 JSP 在我运行时出现错误 404 谁能帮我找出我的错误在哪里?我创建了带有请求参数(背景颜色)并响应的 jsp 页面。我需要从 java 类中调用方法。我还将我的 JSP 页面放在 WEB-INF 文件夹中。这是我的代码。
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="com.java.MyJsp"%>
<!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>Insert title here</title>
</head>
<body>
<form action="./myjsp.jsp">
<input type="radio" name="color" value="color1" > Yellow<br>
<input type="radio" name="color" value="color2"> White<br>
<input type="radio" name="color" value="color3"> Gray<br>
<input type="submit" value="go">
</form>
<% String colors[]=request.getParameterValues("color");
for(int i=0;i<colors.length;i++){
if(colors[i].equals("")||colors[i]==null){ %>
<body style="background-color:<%=com.java.Myjsp.myColor()
%>;">
<% }
if(colors[i].equals("yellow")){
out.println("<html> <style> body{background-color:yellow;} </style>
</html>");
}
if(colors[i].equals("white")){
out.println("<html> <style> body{background-color:white;} </style>
</html>");
}
if(colors[i].equals("gray")){
out.println("<html> <style> body{background-color:gray;} </style>
</html>");
}
}
%>
</body>
</html>
【问题讨论】:
-
你如何在浏览器中访问你的jsp页面?
-
我只是在 eclipse ee 上的服务器上运行
-
发布你的服务器代码和
url你正在访问 -
我将我的 JSP 页面放在了 web INF 中,这是一个原因吗?