学习sturts2时出现的不能加载action问题
来源:互联网 发布:域名备案流程 编辑:程序博客网 时间:2024/05/30 23:33
前几天学习struts2时遇到一个比较苦恼的问题,之前解决了,但是希望更多像我一样的人可以解决,所以把问题发表出来。
在搭建struts2环境时做了一个简单的小测试,没有写index.jsp页面,只写了一个action类,运行tomcat时没有报严重异常,然后直接打开 http://localhost:8080/MySpring4_ssh/UserAtion.action
结果出现这个问题:
配上我的类文件和配置文件:
Useraction类:
package com.test.action;import com.opensymphony.xwork2.ActionSupport;public class UserAction extends ActionSupport{ public UserAction() {System.out.println("action.......");}@Override public String execute() throws Exception { // TODO Auto-generated method stub return NONE; }}
struts.xml文件:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE struts PUBLIC"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN""http://struts.apache.org/dtds/struts-2.3.dtd"><struts><package name="demo1" extends="struts-default" namespace="/"><action name="userAction" class="com.test.action.UserAction"></action></package></struts>
web.xml文件:
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> <display-name>MySpring4_ssh</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>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list></web-app>
检查很多遍这几个文件都没有错,结果很苦恼,千辛万苦百度尝试了很多种方法,结果找到方法:
在sturts.xml文件的<action>上加入这样的一句话:
<default-action-ref name="userAction" />
这句话的意思是如果在web.xml文件的welcome-file中定义的文件找不到,就会交给default-action-ref处理。自动跳转到userAction问题就解决了。原因我也不太理解,Baidu不出答案,但是我觉得,结合以前学习jsp/servlet时候的问题,直接访问WEB-INF里的jsp文件也会报错,应该是现在新版eclipse,运行web项目时会先执行welcome-file的文件,找不到的话就会报错。
阅读全文
0 0
- 学习sturts2时出现的不能加载action问题
- Sturts2中action各项配置的默认值
- ajax中出现js错误不能加载的小问题
- 关于Sturts2在校验不通过的情况下出现报错no result defined for action result input
- sturts2: jsp 与action之间的list传送
- 关于sturts2和FCKeditor的一些问题
- Sturts2学习:理解bean元素的作用
- sturts2框架的学习笔记,问题解决:
- IDEA不能加载API的问题,解决ctrl+左击出现 complex code的问题
- Module加载时出现的问题
- 加载shp mxd时出现的问题
- UIWebView加载PDF时出现的问题
- 使用简单工厂模式出现程序集不能加载的问题的解决方案
- action的一个初始化加载的问题
- Sturts2和Hibernate整合可能会出现的错误
- .Net环境水晶报表在98下发布,出现"不能加载报表..."问题的解决
- 加载模块出现的问题
- JNA调用dll出现不能加载dll问题
- 题目128 前缀式计算
- vagrant创建多节点虚拟机
- 树莓入手
- 0-1背包问题
- 备忘随笔-NDK制作
- 学习sturts2时出现的不能加载action问题
- 我的第一篇博客
- JdbcTemplate的总结
- DrawerLayout侧滑列表
- 备忘随笔-android platform key
- 从零开始前端学习[6]:关于html5的元素类型转换,行级元素,块级元素,行块级元素类型
- 构造函数、析构函数、拷贝构造函数、赋值函数
- 【知了堂学习笔记】c3p0连接池
- 【网页】在网页中添加隐藏播放器自动播放背景音乐的办法