HTTP Status 404 - /Struts2_0100_Introduction/hello.action 错误
struts.xml<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!--
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<include file="example.xml"/>
<package name="default" namespace="/" extends="struts-default">
<default-action-ref name="index" />
<action name="index">
<result type="redirectAction">
<param name="actionName">HelloWorld</param>
<param name="namespace">/example</param>
</result>
</action>
</package>
-->
<package name="default" namespace="/" extends="struts-default">
<action name="hello">
<result>
/Hello.jsp
</result>
</action>
</package>
<!-- Add packages here -->
</struts>
Hello.jsp
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%
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>HelloStruts2</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
Hello Struts2 <br>
</body>
</html>
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">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
项目名字:Struts2_0100_Introduction
就是不知道哪里有问题??是少极了jar包还是其他的问题?搞了我一夜也没搞好 郁闷啊
给位大侠高手给小弟点意见啊 ~~ --------------------编程问答-------------------- 不懂,友情支持! --------------------编程问答-------------------- 配置没有问题 .. 你看启服务器的时候是不是报错导致启动失败 --------------------编程问答-------------------- tomcat启动没有报错啊 没有错误和警告啊 --------------------编程问答-------------------- 出错信息哪
你那STRUTS.XML的配置里面两个PACKAGE的namespace和NAME相同? --------------------编程问答--------------------
人家注释了一个捏 --------------------编程问答-------------------- 学习者 --------------------编程问答-------------------- 问题终于解决~是Myeclipse的BUG 我原来的tomcat安装目录是
C:\Program Files\apache-tomcat-6.0.18 有一个空格
修改目录后: C:\apache-tomcat-6.0.18 没有空格
也就是说 有空格的tomcat安装目录MyEclipse时报错的 大家安装tomcat是一定要注意安装目录不能有空格
搞了我两天 晕死啊 --------------------编程问答--------------------
..
这个问题 重部署的时候会报空指针异常的 所以以后注意了 --------------------编程问答-------------------- <welcome-file>index.jsp</welcome-file>
这个的index.jsp 改成Hello.jsp --------------------编程问答-------------------- 那就是要重新安装一下tomcat,对吗? --------------------编程问答-------------------- 但是按照网上的tomcat 安装步骤,写一个jsp 程序的时候也能看到效果啊!
补充:Java , Web 开发