web.xml:
<welcome-file-list> <welcome-file>/WEB-INF/index.jsp</welcome-file> </welcome-file-list> </web-app>
我的工程名是ZS,当我访问http://localhost:8080/ZS/时,出现下面的提示。
There is no Action mapped for action name /WEB-INF/index.jsp. - [unknown location] com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:189) org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61) org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39) com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58) org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:475) org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
但是我访问http://localhost:8080/ZS/register/init时(项目中的注册画面)却能正常显示,请问这是为什么?
有没有定义跳转到index.jsp的action呢?
因为你的欢迎界面是index.jsp,所以你输入http://localhost:8080/ZS/时,会自动去找index.jsp,但是struts的配置文件里没有定义这个action,就会抛出异常。
可以在
index.jsp
index.action
需要在struts中定义个index.action,利用这个action跳转到index.jsp。
因为你把你的主页index.jsp放在了WEB-INF的目录下面,那么通过url路径是访问不到的。
只有通过内部在能去访问到。就是你上面用的。
给此页面配置一个action去跳转到它,这样就能访问得到。这么做也算是一种安全的考虑,如果能通过url直接访问的话,可能就不安全了。
你改完后页面报的是什么错误信息?还是404?
你这个是什么时候报的错?是tomcat启动的时候吗?还是你输入地址的时候?
如果按照你上面的配置服务启动后输入地址localhost:8080/ZS/就应该是index.jsp了。
不可能有问题。
[quote]/WEB-INF/index.jsp [/quote]
好好检查下这个位置!404 不是什么大问题!
估计这块 配置改了几次! 都乱了!
[color=red]/[/color]WEB-INF/index.jsp 去掉那个 /
这是tomcat得一种安全措施.从外部是不能直接访问WEB-INF目录的.你可以通过Action转发过去访问.