各位帮我看看我这样的配置 有木有啥问题。我是看马士兵的视频,然后复制过来的(至于复制的文件,有错误,我也不知道,下面列出了我的xml jsp 文件)
当我输入http://localhost:8080/Struts2_0200_Namespace/front/index
为何显示不了呢 提示HTTP Status 404 - /Struts2_0200_Namespace/front/index 错误!!!我刚刚接触框架,表示很补懂,求各位教教我丫
<?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> <package name="front" extends="struts-default" namespace="/front">
<action name="index">
<result>/Namespace.jsp</result>
</action>
</package>
<package name="main" extends="struts-default" namespace="">
<action name="index">
<result>/Namespace.jsp</result>
</action>
</package></struts>
这是我的struts.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>
这是我的web.xml文件<?xml version="1.0" encoding="GB18030" ?>
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030" />
<title>Insert title here</title>
</head>
<body>
namespace决定了action的访问路径,默认为"",可以接收所有路径的action<br />
namespace可以写为/,或者/xxx,或者/xxx/yyy,对应的action访问路径为/index.action,
/xxx/index.action,或者/xxx/yyy/index.action.<br/>
namespace最好也用模块来进行命名
</body>
</html>这是的我jsp文件
当我输入http://localhost:8080/Struts2_0200_Namespace/front/index
为何显示不了呢 提示HTTP Status 404 - /Struts2_0200_Namespace/front/index 错误!!!我刚刚接触框架,表示很补懂,求各位教教我丫
<?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> <package name="front" extends="struts-default" namespace="/front">
<action name="index">
<result>/Namespace.jsp</result>
</action>
</package>
<package name="main" extends="struts-default" namespace="">
<action name="index">
<result>/Namespace.jsp</result>
</action>
</package></struts>
这是我的struts.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>
这是我的web.xml文件<?xml version="1.0" encoding="GB18030" ?>
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030" />
<title>Insert title here</title>
</head>
<body>
namespace决定了action的访问路径,默认为"",可以接收所有路径的action<br />
namespace可以写为/,或者/xxx,或者/xxx/yyy,对应的action访问路径为/index.action,
/xxx/index.action,或者/xxx/yyy/index.action.<br/>
namespace最好也用模块来进行命名
</body>
</html>这是的我jsp文件
解决方案 »
- 一直不解,Atom跟Json该用哪个?
- 四川久远新方向 怎么样
- 讨论:开发中有直接使用springMVC的吗?或者说springMVC用处大吗
- 字符串替换问题
- 请问jsp中如何实现rmi?
- 谁能发份STRUTS 1.0.2给我,不盛感谢!立即给分
- 求日志管理类的代码!谢谢!
- 初学SSH,请大神们指点!
- 如何将一个用户名和密码同时保存到不同的数据库中
- 急!!!tomcat项目下的包里有图片,但是eclipse项目里对应的包刷新也没有图片
- activemq生产者和消费者的关系是怎么确定的?
- jbpm4.4 spring3.0 hibernate 集成错误 急!急!急!could not initialize proxy - no Session
试过了 url 没问题
<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>过滤的是是对 /* 所以你改成这个:http://localhost:8080/Struts2_0200_Namespace/front/index.action尝试一下吧!
试过了 显示HTTP Status 404 - /Struts2_0200_Namespace/front/index.action
这怎么发啊 貌似csdn发不了图片啊
应该是.action了
你试试在你的struts.xml中配置这样一个试试
在packge便签外面添加这样一句了
<constant name="struts.action.extension" value="do,action"></constant>
这个表示是说你请求的时候可以用http://localhost:8080/Struts2_0200_Namespace/front/index.do或者
http://localhost:8080/Struts2_0200_Namespace/front/index.action来跳转到action中
我刚刚接触框架 希望高手细心教教上面的xml 文件是我直接从课程的代码 直接复制下来的 路径没问题呀呵呵
这个地方都没有返回结果,就没有办法跳转到对应的页面吧!
<result name="XXXX">/Namespace.jsp</result>
XXX表示后台action代码中return的返回值。
我怀疑是不是忘记加了.jsp
因为你的项目欢迎页面是xml里面配置的 index.jsp
正确,为Struts2_0200_Namespace
<result name="XXXX">/Namespace.jsp</result>这句的name="XXXX" 是可以省略的