如何让struts2看到我的属性文件 [英] How make struts2 see my properties file

查看:73
本文介绍了如何让struts2看到我的属性文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个项目结构

,在我的index.jsp中,我有以下代码:

and in my index.jsp I have this code:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
  <head>
    <title>
        <s:text name="index.title" />
    </title>
  </head>
  <body>
    <s:form action="Login">
        <s:textfield key="index.login" name="login" />
        <s:password key="index.password" name="password" />
        <s:submit/>
    </s:form>
  </body>
</html>

我的content.property文件如下所示:

index.hello = Hello user./n/r Please login
index.login = Login
index.password = Password
index.title = Login Page

并且当我启动项目时,struts2没有从我的属性文件中获取信息. 请告诉我我做错了什么 我在互联网上找不到任何有用的信息 请帮帮我 谢谢=)

and when i start the project, struts2 is not getting info from my property file. please tell me what i made wrong I can't find anything helpful on the internet help me please thanks =)

推荐答案

您的属性文件必须位于WEB-INF下的classes目录中或classes目录的子目录中.

Your properties file needs to be in the your classes directory under WEB-INF or a sub-directory of classes directory.

让我们假设您具有这种结构 .../Web-INF/classes/property/content.properties, 您将需要在struts.xml

Let's assume that you have this structure .../Web-INF/classes/property/content.properties, you will need to do this in your struts.xml

<constant name="struts.custom.i18n.resources" value="property.content" />

这篇关于如何让struts2看到我的属性文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆