第48月第19天 struts2 spring整合 html utf-8

1.

第七步,把UserAction交给Spring进行配置,即在Spring配置文件中添加如下配置:

<!-- 配置action对象 -->
<bean id="userAction" class="cn.itcast.action.UserAction" scope="prototype"></bean>
  • 1
  • 2

这时,在Spring配置文件——bean1.xml中配置了UserAction对象,在Struts2配置文件——struts.xml中也配置了UserAction对象。很显然,这种做法是不可取的。解决思路是只需要在Spring配置文件里面配置UserAction对象,而不要在Struts2配置文件中配置。所以,Struts2配置文件应该改为:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
    "http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
    <package name="demo" extends="struts-default" namespace="/">
        <!-- 在action标签里面不要写action全路径,class属性值写在Spring配置action对象的bean标签的id值 -->
        <action name="user" class="userAction"></action>
    </package>
</struts>


https://blog.csdn.net/yerenyuan_pku/article/details/70040220


2.struts2 action接收对象

解决了
好像action中的对象必须new一个才行
我使用了
Admin admin = new Admin();
就成功了。

https://www.iteye.com/problems/25570


3.html utf-8

 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />




原文地址:https://www.cnblogs.com/javastart/p/13697369.html