czzy
作者czzy·2010-09-08 11:02
系统工程师·

WebSphere欢迎页问题实例解析(rabby)

字数 2232阅读 3382评论 0赞 1
最近,在把一个项目从tomcat移植到websphere上时遇到一个问题,项目使用struts2作为控制器,部署在tomcat时,输入http://localhost:8080/spgweb/,可以直接跳转到login.jsp页面,但部署到websphere上后,输入http://localhost:9080/spgweb/,却直接跳转到Error404.jsp页面(spgweb为项目名称)。

web.xml配置如下:

<display-name>spgweb</display-name>
 <filter>
  <filter-name>jspfilter</filter-name>
  <filter-class>com.huawei.spgweb.util.JspFilter</filter-class>
 </filter>
 <filter-mapping>
  <filter-name>jspfilter</filter-name>
  <url-pattern>*.jsp</url-pattern>
 </filter-mapping>
 <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>page/login.jsp</welcome-file>
 </welcome-file-list>
 <error-page>
  <error-code>404</error-code>
  <location>/Error404.jsp</location>
 </error-page>
 <error-page>
  <error-code>500</error-code>
  <location>/Error500.jsp</location>
 </error-page>

     google、baidu了一把,也没找着答案,只好自己动手解决了!根据服务器返回的错误描述,是找不到action,难道是webshpere容器并未对http://localhost:9080/spgweb/进行处理,直接交给了struts2?如果是这样,当然找不着action了,那么,action的名字应该是什么呢?难道是空("")!想到这里,果断的加一action:

 

public class RedirectAction extends ActionSupport {
 private static final long serialVersionUID = -6051489996510006694L;

 

 @Action(
   value="",       //action的名字为空
   results={
     @Result(name=ActionSupport.LOGIN,location="/page/login.jsp")
   }
 )
 @Override
 public String execute() throws Exception {
  return ActionSupport.LOGIN;
 }
}

重新测试一下,输入http://localhost:9080/spgweb/,已可正常跳转到login.jsp页面,问题解决!

作者:rabby

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

1

添加新评论0 条评论

Ctrl+Enter 发表

作者其他文章

相关文章

相关问题

相关资料

X社区推广