struts2图片路径问题

x8023x 2009-12-21 09:55:51
<img src="/pic/图片1.jpg"/>
用户上传一张图片 难免出现中文名字,英文正常显示,中文怎么解决?
...全文
215 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
如果你用 tomcat的话,打开conf/server.xml找到
<Connector
port="8080" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"
URIEncoding="UTF-8" useBodyEncodingForURI="true" />
<!-- Note : To disable connection timeouts, set connectionTimeout value
to 0 -->
加上红色的部分就行了
crazylaa 2009-12-21
  • 打赏
  • 举报
回复
上传的时候改下文件名比较好,然后原始文件名存起来。要不同名文件会覆盖掉
BearKin 2009-12-21
  • 打赏
  • 举报
回复
正确的解决方法都是上传的同时更改文件名 同时保存原本的文件名 如果说该文件仅仅是用来作为图片显示的话 那就更没必要保存原来的文件名了
zl3450341 2009-12-21
  • 打赏
  • 举报
回复
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

web.xml里面配置一下
yang677888 2009-12-21
  • 打赏
  • 举报
回复
用过滤器
scutpt 2009-12-21
  • 打赏
  • 举报
回复
在struts.xml配置文件中配置
<constant name="struts.i18n.encoding" value="GBK"></constant>
就可以了
happygao521 2009-12-21
  • 打赏
  • 举报
回复
设置编码就可以了,gbk或者utf-8
sean1203 2009-12-21
  • 打赏
  • 举报
回复
google把

67,513

社区成员

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

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