配置struts2.3版本的,和以前有所不同,struts.xml是放在src下没有变。
不同的是里面的内容:
struts.xml:
1 <?xml version="1.0" encoding="UTF-8" ?> 2 3 <!DOCTYPE struts PUBLIC 4 5 "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" 6 7 "http://struts.apache.org/dtds/struts-2.1.dtd"> 8 9 <!-- 10 11 struts配置详解: package 表示包 name="struts2" 遵循命名规范 namespace 命名空间 extends 12 13 继承 表示包继承了某些包的功能 action name表示请求的名称 class 表示处理请求url converter="" 14 15 表示在请求中需要转换的类型参数 method 一个action中处理不同的请求方法 <result 16 17 name="表示和action中要执行的方法的返回值对应" type=""></result> type表示返回的结果类型 18 19 --> 20 21 <struts> 22 23 <!-- <constant name="struts.i18n.encoding" value="UTF-8" /> --> 24 25 <package name="struts2" extends="struts-default" > 26 27 <action name="hello" class="com.action.HelloAction" > 28 29 <result name="success">/welcome.jsp</result> 30 31 </action> 32 33 </package> 34 35 </struts>
配置的时候发现出现404的问题,在web.xml,配置和以前不同了。
web.xml:
1 <?xml version="1.0" encoding="UTF-8"?> 2 3 <web-app version="2.5" 4 5 xmlns="http://java.sun.com/xml/ns/javaee" 6 7 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 8 9 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 10 11 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> 12 13 14 15 <filter> 16 17 <filter-name>struts2</filter-name> 18 19 <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> 20 21 </filter> 22 23 <filter-mapping> 24 25 <filter-name>struts2</filter-name> 26 27 <url-pattern>/*</url-pattern> 28 29 </filter-mapping> 30 31 <!-- ... --> 32 33 <welcome-file-list> 34 35 <welcome-file>index.jsp</welcome-file> 36 37 </welcome-file-list> 38 39 </web-app>
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 继承的思维:从思维模式到架构设计的深度解析
· 如何在 .NET 中 使用 ANTLR4
· 后端思维之高并发处理方案
· 理解Rust引用及其生命周期标识(下)
· 从二进制到误差:逐行拆解C语言浮点运算中的4008175468544之谜
· Cursor预测程序员行业倒计时:CTO应做好50%裁员计划
· 想让你多爱自己一些的开源计时器
· 大模型 Token 究竟是啥:图解大模型Token
· 用99元买的服务器搭一套CI/CD系统
· 当职场成战场:降职、阴谋与一场硬碰硬的抗争