求解决,无法通过action跳转到jsp页面

qq_33770784 2017-02-28 07:49:01
<?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>

<constant name="struts.devMode" value="false" />
<package name="shop" namespace="/" extends="struts-default">

<!-- 配置首页访问的action -->
<action name="index" class="indexAction">
<result name="index">/WEB-INF/jsp/index.jsp</result>
</action>

<!-- 配置访问注册的action -->
<action name="user_*" class="userAction" method="{1}">
<result name="registPage">/WEB-INF/jsp/regist.jsp</result>
</action>
</package>
</struts>

这个是applicationContext的配置

<!-- Action的配置 ===========================-->

<!-- 首页访问的Action -->
<bean id="indexAction" class="in.itcast.shop.index.action.IndexAction" scope="prototype">

</bean>

<!-- 配置验证码Action -->


<!-- 用户模块的Action -->
<bean id="userAction" class="in.itcast.shop.user.action.UserAction" scope="prototype">
<!-- 注入Service -->

</bean>

这是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">
<!-- 配置Spring的核心监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>

<!-- 配置Struts2的核心过滤器 -->
<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>
<display-name></display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>



package in.itcast.shop.index.action;

import com.opensymphony.xwork2.ActionSupport;

/*
* 引入首页访问Action
*/
public class IndexAction extends ActionSupport{



/**
*
*/
private static final long serialVersionUID = 1L;

public String execute(){

return "index";
}

}
Action类,就只有一个重写的方法另外一个类也是如此,求帮助。

...全文
361 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_33770784 2017-03-01
  • 打赏
  • 举报
回复
真的是想哭,昨天弄了一晚上,结果我刚刚启动并访问index.action就没有问题了,我勒个去。谢谢各位的回答。
qq_33770784 2017-03-01
  • 打赏
  • 举报
回复
应为我的JSP页面都在WEB-INF目录jsp文件下面。
jiajing1990_ 2017-03-01
  • 打赏
  • 举报
回复
<result name="registPage">/WEB-INF/jsp/regist.jsp</result> 为什么还要加上WEB-INF???
ryuugu_rena 2017-03-01
  • 打赏
  • 举报
回复
貌似看不出什么问题,报的什么错?贴出来
自由自在_Yu 2017-03-01
  • 打赏
  • 举报
回复
jsp呢

67,549

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧