struts标签库:配置和使用

struts标签库的配置和使用

配置:
	* 配置国际化支持,在struts-config.xml文件中加入如下配置:
	<message-resources parameter="MessageResources" />
	* 最好提供国际化资源文件(MessageResources.properties),将该文件放到src下
	
使用:
	采用taglib引入
	<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>     
	<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>      
		
		
		
MessageResources.properties
# -- standard errors --
errors.header=<UL>
errors.prefix=<LI>
errors.suffix=</LI>
errors.footer=</UL>
# -- validator --
errors.invalid={0} is invalid.
errors.maxlength={0} can not be greater than {1} characters.
errors.minlength={0} can not be less than {1} characters.
errors.range={0} is not in the range {1} through {2}.
errors.required={0} is required.
errors.byte={0} must be an byte.
errors.date={0} is not a date.
errors.double={0} must be an double.
errors.float={0} must be an float.
errors.integer={0} must be an integer.
errors.long={0} must be an long.
errors.short={0} must be an short.
errors.creditcard={0} is not a valid credit card number.
errors.email={0} is an invalid e-mail address.
# -- other --
errors.cancel=Operation cancelled.
errors.detail={0}
errors.general=The process did not complete. Details should follow.
errors.token=Request could not be completed. Operation is not in sequence.
# -- welcome --
welcome.title=Struts Blank Application
welcome.heading=Welcome!
welcome.message=To get started on your own application, copy the struts-blank.war to a new WAR file using the name for your application. Place it in your container's "webapp" folder (or equivalent), and let your container auto-deploy the application. Edit the skeleton configuration files as needed, restart your container, and you are on your way! (You can find the application.properties file with this message in the /WEB-INF/src/java/resources folder.)

	
	

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
YOLO高分设计资源源码,详情请查看资源内容中使用说明 YOLO高分设计资源源码,详情请查看资源内容中使用说明 YOLO高分设计资源源码,详情请查看资源内容中使用说明 YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明
要在 JSP 项目中配置 Struts2,需要遵循以下步骤: 1. 引入 Struts2 :将 Struts2 添加到项目的 classpath 中。可以从 Struts2 官网上下载最新版本的文件。 2. 配置 web.xml:在 web.xml 文件中添加 Struts2 的配置信息。可以参考以下示例: ``` <web-app> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.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> </web-app> ``` 3. 配置 struts.xml:创建一个名为 struts.xml 的配置文件,并将其放置在项目的类路径下。该文件包含了 Struts2 框架的配置信息,例如拦截器、Action 等。可以参考以下示例: ``` <struts> <package name="default" extends="struts-default"> <action name="hello" class="com.example.HelloAction"> <result name="success">/hello.jsp</result> </action> </package> </struts> ``` 在上面的示例中,定义了一个名为 "hello" 的 Action,它的类为 com.example.HelloAction,并且成功时返回 /hello.jsp 页面。 4. 创建 Action 类:创建一个 Java 类来处理请求并返回响应。可以继承 ActionSupport 类,该类提供了一些常用的方法,例如获取请求参数、设置响应结果等。可以参考以下示例: ``` public class HelloAction extends ActionSupport { private String message; public String execute() { message = "Hello, world!"; return SUCCESS; } public String getMessage() { return message; } } ``` 在上面的示例中,定义了一个名为 "message" 的属性和一个名为 "execute" 的方法,该方法返回 SUCCESS 常量。 5. 创建 JSP 页面:创建一个 JSP 页面来显示响应结果。可以参考以下示例: ``` <%@ taglib prefix="s" uri="/struts-tags"%> <html> <head> <title>Hello, world!</title> </head> <body> <h1><s:property value="message"/></h1> </body> </html> ``` 在上面的示例中,使用 Struts2 标签的 s:property 标签来显示 "message" 属性的值。 完成上述步骤后,就可以在 JSP 项目中使用 Struts2 来处理请求和返回响应了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值