解决404和there is no action mapped for action的问题
来源:互联网 发布:wingide ubuntu 编辑:程序博客网 时间:2024/05/17 06:49
首先,我要严重吐槽eclipse,我的是eclipseEE版本,使用起来大概就不如Myeclipse吧,导致各种问题,
这几天一直被404这个问题困扰,毕竟我只是个学Android的,跑来学习web,小白一名,各个查阅中华上下五千年,各种尝试大神的方法,结果还是没解决我的问题。今天终于在一次被激怒的情况下重启了一下eclipse,结果发现竟然没有异常没有404了,检查了各种web.xml和struts.xml和各种东西,路径也没放错,配置等也是正确的,所以如果现在你也在困扰这个问题,不如重启一下你的IDE吧,看了好的大神的方法,这里也简单的总结一下他们的方法吧:
(1)可能是你的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><package name="example" namespace="" extends="struts-default"><action name="Login" class="action.LoginAction"><result>/loginResult.jsp</result><result name="input">/login.jsp</result></action></package></struts>我的是做一个小小的登录界面,登录成功的话跳转到loginResult页面,不成功则返回错误信息。
(2)可能是web.xml引起错误,导致你的配置没成功。这里先贴出我的代码:
<?xml version="1.0" encoding="UTF-8"?><web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"><display-name>strutsdemo</display-name> <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> <welcome-file-list> <welcome-file>login.jsp</welcome-file> </welcome-file-list></web-app>其中<display-name>是web应用配置的显示名称,可有可无,问题不大这里。
<filter-class>表示过滤器对应的类,<filter-mapping>中的<url-pattern>指出过滤匹配的URL模式,设为/*为均匹配。
<welcome-file-list>表示web应用启动时默认访问的文件,这里我设置为login.jsp为默认,如果不设的话则在
中手动添加login.jsp,再运行其实问题也不大。
(3)struts.xml放错位置。struts.xml我的是放入到src文件夹下的,看别的大神说这个文件在编译的时候会自动放到classes文件下,所以你也可以检查一下你的路径问题,
这里贴出我的工程目录
(4)在建工程的时候修改相应的配置
将build\classes改为WebContent\WEB-INF\classes,运行工程时检查一下你的classes文件夹下有没有.class的文件,因为编译时会把二进制文件放入到这个文件夹上,同样这里也会有struts.xml文件的拷贝
这里可以看到有相应的目录和文件生成,点击action文件夹时,里面会有相应的.class文件,就是你的.java文件编译后得到的文件。
(5)这里补充一下怎么在eclipse中查看classes文件夹吧,因为默认时是不会打开这个视图的,
所以我们需要在eclipse的windows-->show view-->navigator打开视图。
说了那么多,其实我也是看了好的别人的方法才总结一下的,毕竟我只是想web入门而已,如果上文有哪些补充或者错误,望大神补充,小弟不胜感激!!!
- 解决404和there is no action mapped for action的问题
- Struts 中There is no Action mapped for namespace / and action name...问题的解决
- There is no Action mapped for action
- Struts2 找不到Action的问题:There is no Action mapped for action name XXXX. - [unknown location]
- 解决There is no Action mapped for namespace for****异常
- There is no Action mapped for namespace / and action name login.的解决
- Struts2中关于"There is no Action mapped for namespace / and action name"的错误解决
- 解决"There is no Action mapped for namespace / and action name ***"的方法
- There is no Action mapped for namespace
- There is no Action mapped for namespace
- There is no Action mapped for namespace
- There is no Action mapped for namespace / and action name 问题的解决办法
- There is no Action mapped for namespace [/] and action name [login] associat...问题的另一个思路
- Struts2中关于"There is no Action mapped for namespace / and action name"的问题
- 使用Struts2遇到There is no action mapped for namespaces / and action name的问题
- 我遇到的问题: There is no Action mapped for namespace [/] and action name
- There is no Action mapped for namespace / and action name .
- There is no Action mapped for namespace / and action name
- The Java™ Tutorials
- ubuntu缺少public-key问题
- explorer.exe不是有效的Win32应用程序
- 快速幂取余
- Linux界面切换
- 解决404和there is no action mapped for action的问题
- 深入理解tcp关闭连接的过程
- Swiper学习--- 中文API手册
- 【个推推送】如果接受不到推送,如果你确定所有的xml配置都是好的
- HDU 5672 String(尺取法)
- Accessing Members of an Enclosing Class
- 系统从win7更新到win10没有声音(扬声器一直显示未插入)
- Myeclipse10.x破解方法
- 【Android 学习】小知识Notification的新旧用法