404错误问题

summer-smile 2014-04-19 03:11:54
web.xml页面代码:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>control_servlet</servlet-name>
<servlet-class>com.control.control_servlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>control_servlet</servlet-name>
<url-pattern>com.control/control_servlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>view.jsp</welcome-file>
</welcome-file-list>
</web-app>





JSP界面代码:


<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>体重测试</title>

</head>

<body>
<center>
<font color=red size=5 >看看你的体重状态如何</font>
<hr style="BORDER-BOTTOM-STYLE: dotted; BORDER-LEFT-STYLE: dotted; BORDER-RIGHT-STYLE: dotted; BORDER-TOP-STYLE: dotted" color=blue size=1 width=100%>

<form name="view" action="com.control/control_servlet" method="post">
    体重<input type="text" name="weight" value="">公斤<br>
身高 <input type="text" name="height" value="">米<br>

<input type="submit" value="提交">  
<input type="reset" value="重填">

</form>
</center>
</body>
</html>




路径问题 不知道怎么解决
...全文
113 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
404是什么东西404呢?是运行项目404,还是提交后404,多么歧义。
浪里花 2014-04-21
  • 打赏
  • 举报
回复
<url-pattern>com.control/control_servlet</url-pattern>加个斜杠/com.control/control_servlet <form name="view" action="com.control/control_servlet" method="post">最好这样 <form name="view" action="<%=path%>/com.control/control_servlet" method="post"> 不这样的话你的action表示的是相对路径,一般用绝对路径好点
tony4geek 2014-04-21
  • 打赏
  • 举报
回复
具体点的信息。
davidworld 2014-04-19
  • 打赏
  • 举报
回复
<url-pattern>com.control/control_servlet</url-pattern>改为<url-pattern>/com.control/control_servlet</url-pattern> 试下

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧