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.devMode" value="true" /> <package name="default" namespace="/" extends="struts-default">
<!-- 默认Action -->
<default-action-ref name="index"></default-action-ref>
<action name="index">
<result>/test.jsp</result>
</action>
</package>
</struts>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">
<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>
该加的包也都加了,处理其他的Action都可以就是这个默认Action不可以,不知道为什么,假如项目名为PP,那么在浏览器中输入http://localhost:8080/PP之后,显示的结果还是index.jsp中的内容,我已经在web.xml中把welcome-file删了,为什么还是显示index.jsp呢,搞不懂,默认的Action为什么不执行呢,即使输入http://localhost:8080/PP/fsdfsd也不行。我把namespace=“/user”,然后输入http://localhost:8080/PP/user/还是不行,只有输入http://localhost:8080/PP/user/index时才显示test.jsp里面的内容,为什么啊,请大侠指点!
<?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.devMode" value="true" /> <package name="default" namespace="/" extends="struts-default">
<!-- 默认Action -->
<default-action-ref name="index"></default-action-ref>
<action name="index">
<result>/test.jsp</result>
</action>
</package>
</struts>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">
<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>
该加的包也都加了,处理其他的Action都可以就是这个默认Action不可以,不知道为什么,假如项目名为PP,那么在浏览器中输入http://localhost:8080/PP之后,显示的结果还是index.jsp中的内容,我已经在web.xml中把welcome-file删了,为什么还是显示index.jsp呢,搞不懂,默认的Action为什么不执行呢,即使输入http://localhost:8080/PP/fsdfsd也不行。我把namespace=“/user”,然后输入http://localhost:8080/PP/user/还是不行,只有输入http://localhost:8080/PP/user/index时才显示test.jsp里面的内容,为什么啊,请大侠指点!
解决方案 »
- struts像javascript传递参数的问题
- 关于spring3.0的拦截器
- String str = session.getId();这样得到的是sessionid吗?
- 兄弟门,为什么这样啊!
- 关于Lucene搜索结果的问题:IndexSearch与Hits
- 用jsp翻译一下这段PHP代码,谢谢了!大家请帮忙吗
- 急!!!Remote Back-up System Using Web Services
- struts能和纯html写的jsp一起使用吗?怎样使用?
- 怎样解决用户在其他机器上登录会提示“用户已经在其他机器上登录”?
- 关于 Hadoop HDFS中的fsimage
- 奇怪现象!hibernate hql执行update不报异常,不执行
- RMIJDBC中getBinary()方法调用出错,求原因
<jsp:forward page="/servlet/login" />
<jsp:forward page="/servlet/login">
<jsp:param name="username" value="jsmith" />
</jsp:forward>
然后在工程的webcontent下建立一个index的空文件。没有扩展名。
action是要有东西触发才能执行的。