新手求教,刚接触struts2,遇到配置的问题

appleYQL 2017-03-11 03:13:05
RT,我用这样访问时提示找不到映像文件:http://localhost:8080/TestStruts/struts0.action下面是配置:
首先这是项目文件的位置:
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>

<!-- <constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="true" />

<package name="default" namespace="/" extends="struts-default">

<default-action-ref name="index" />

<global-results>
<result name="error">/WEB-INF/jsp/error.jsp</result>
</global-results>

<global-exception-mappings>
<exception-mapping exception="java.lang.Exception" result="error"/>
</global-exception-mappings>

<action name="index">
<result type="redirectAction">
<param name="actionName">HelloWorld</param>
<param name="namespace">/example</param>
</result>
</action>
</package>

<include file="example.xml"/> -->

<!-- Add packages here -->
<package name="default" namespace="/" extends="struts-default">
<default-action-ref name="index" />

<global-results>
<result name="error">/WEB-INF/jsp/error.jsp</result>
</global-results>

<global-exception-mappings>
<exception-mapping exception="java.lang.Exception" result="error"/>
</global-exception-mappings>
<action name="struts0">
<result type="redirectAction">/struts0.jsp</result>
</action>
</package>
</struts>

web.xml的配置:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

<display-name>Struts Blank</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.jsp</welcome-file>
</welcome-file-list>

<!-- Restricts access to pure JSP files - access available only via Struts action -->
<security-constraint>
<display-name>No direct JSP access</display-name>
<web-resource-collection>
<web-resource-name>No-JSP</web-resource-name>
<url-pattern>*.jsp</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>no-users</role-name>
</auth-constraint>
</security-constraint>

<security-role>
<description>Don't assign users to this role</description>
<role-name>no-users</role-name>
</security-role>

</web-app>
...全文
147 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
appleYQL 2017-03-11
  • 打赏
  • 举报
回复
引用 5 楼 appleYQL 的回复:
[quote=引用 3 楼 u012934325 的回复:]
http://blog.csdn.net/u012934325/article/details/50602959

看了你的那个帖子,修改后如果 不加<constant name="struts.devMode" value="true" />这句话也会报错==[/quote]
找到错误了,不是type那里的问题,而是缺少<constant name="struts.devMode" value="true" />这句话,粘贴复制过来后注释过头了,另外type的类型这博客里有解释http://www.cnblogs.com/zhengbin/p/4923942.html?utm_source=tuicool&utm_medium=referral
appleYQL 2017-03-11
  • 打赏
  • 举报
回复
引用 3 楼 u012934325 的回复:
http://blog.csdn.net/u012934325/article/details/50602959
看了你的那个帖子,修改后如果 不加<constant name="struts.devMode" value="true" />这句话也会报错==
appleYQL 2017-03-11
  • 打赏
  • 举报
回复
引用 1 楼 cfdxnl 的回复:
你是不是看的尚硅谷?
网易云尚学堂那的
墨笙弘一 2017-03-11
  • 打赏
  • 举报
回复
http://blog.csdn.net/u012934325/article/details/50602959
墨笙弘一 2017-03-11
  • 打赏
  • 举报
回复
struts.xml中action的result type="success"
成盒落地98k 2017-03-11
  • 打赏
  • 举报
回复
你是不是看的尚硅谷?

67,549

社区成员

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

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