struts2 全局信息配置问题

hanyibin 2009-06-04 11:02:16
上传文件是,我限制了上传类型,类型不符合的时候,提示错误信息Content-Type not allowed: file "upload__6e3ab8a_121a91353bf__8000_00000014.tmp" text/plain
我想把系统提示的这个信息覆盖替换,我新建了一个message.properties 文件,里面写了struts.messages.error.content.type.not.allowed=\u53ea\u5141\u8bb8,我现在不知道怎么能让tomcat 找到这个文件,就是怎么能在错误的时候找到我自己设置的这个属性。
我试的在struts.xml 加入<constant name="struts.custom.i18n.resources" value="message"></constant> 也没有效果。
请大家给我指点一下,我该在哪里在配置一下相关信息,谢谢!!
...全文
428 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
penguinwangdan 2009-08-10
  • 打赏
  • 举报
回复
上传其也格式图片没问题,但是上传swf格式的时候出现:Content-Type not allowed: upload "01.swf" "upload_53e4a63a_12303d94c58__7fff_00000005.tmp" application/x-shockwave-flash。
hanyibin 2009-06-05
  • 打赏
  • 举报
回复
通过properties类读取 ???怎么读取 如果你知道就告诉我一下,搜索引擎上我知道该怎么问
redlotus_lyn 2009-06-04
  • 打赏
  • 举报
回复
<constant name="struts.custom.i18n.resources" value="message"> </constant>

把value="message"中message换成别的名字尝试一下。


注:如果上面尝试不好用,在src目录下创建properties文件,不是message.properties就是messages.properties,你尝试一下,我记不清楚了。

在文件中加入struts.messages.error.content.type.not.allowed=\u53ea\u5141\u8bb8。


yebidaxiong 2009-06-04
  • 打赏
  • 举报
回复
沙发,不知到
guotao1982 2009-06-04
  • 打赏
  • 举报
回复
应该是文件存放位置问题
cocofuyi 2009-06-04
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 redlotus_lyn 的回复:]
<constant name="struts.custom.i18n.resources" value="message"> </constant>

把value="message"中message换成别的名字尝试一下。


注:如果上面尝试不好用,在src目录下创建properties文件,不是message.properties就是messages.properties,你尝试一下,我记不清楚了。

在文件中加入struts.messages.error.content.type.not.allowed=\u53ea\u5141\u8bb8。
[/Quote]在src目录下创建properties文件,通过properties类读取
cust28 2009-06-04
  • 打赏
  • 举报
回复
检查 /WEB-INF/classes目录下是否由message.properties这个文件
hanyibin 2009-06-04
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 redlotus_lyn 的回复:]
<constant name="struts.custom.i18n.resources" value="message"> </constant>

把value="message"中message换成别的名字尝试一下。


注:如果上面尝试不好用,在src目录下创建properties文件,不是message.properties就是messages.properties,你尝试一下,我记不清楚了。

在文件中加入struts.messages.error.content.type.not.allowed=\u53ea\u5141\u8bb8。
[/Quote]

这俩个方法我都试了,出不来效果,我感觉还是路径有问题,或者是其他的地方还需要设置什么。

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

<constant name="struts.custom.i18n.resources" value="message"></constant>
<constant name="struts.i18n.encoding" value="utf-8"></constant>

<package name="struts2" extends="struts-default">
<action name="fileUpload" class="com.cntion.test.action.UploadAction">
<result name="success">/upload/result.jsp</result>
<result name="input">/result.jsp</result>
<interceptor-ref name="fileUpload">
<param name="maximumSize">409600</param>
<param name="allowedTypes">image/gif,image/jpeg</param>
</interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
</action>
<action name="fileDownload" class="com.cntion.test.action.Download">
<result name="success" type="stream">
<param name="contentType">${contentType}</param>
<param name="contentDisposition">${fileName}</param>
<param name="inputName">downloadFile</param>
</result>
</action>
</package>
</struts>

这是我的配置文件,我的message.properties文件就建在src 目录下。
lvsh870228 2009-06-04
  • 打赏
  • 举报
回复
路径问题吧

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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