视频:
 上传层中的srcContentType和src从哪里获得?
 setNavigateImageList方法用于何处有何作用?// 获取服务器路径
   String path = ServletActionContext.getServletContext().getRealPath(UecInc.savePath); 
private String srcFileName;//struts2会自动得到文件名
struts2如何自动获得上传的文件的文件名图片存入数据库里?通过流来控制删除图片,如何实现,实现之后此方案是否可行,如何应用在哪些方面?
java中的序列
<!-- 重大项目内容业务层 -->
 <bean id="majorproContentService" class="bgi.portal.service.impl.MajorproContentServiceImpl" scope="prototype">
  <property name="majorproContentDAO" ref="majorproContentDAO"></property>
 </bean> 其中scope="prototype"作用开发问题:
 首先用到了struts2的action,设置该action的scope为prototype
 然后当编辑某个内容时,首先根据该内容id查询实体,然后把信息显示在页面上,
 在页面上比如:<img src="${user.imageUrl}" name="user.imageUrl">
        <input type="text" name="user.username" value="${user.username}"/>
        当我们修改这两个元素,如果上传的图片格式错误,我们将返回该页面提示图片格式错误,
 这样的话我们的username自然不应该去修改它修改之后的信息,比如数据库中的信息的username为tangxin,但是我修改成了yanjia,自然
 yanjia也是合法信息,所以不应该去查询该实体然后替换成tangxin,所以不应该查询实体。设置该action的scope为prototype(前提)
struts2中的action中的bean对象,比如在form表单中不给bean对象赋予原来的属性值,比如:<input type="text" name="user.username" value="${user.username}">
那么它将被赋予空值null 
newsContent.setUrl如何设置?
时间转换类型问题 如何让2011-08-29与2011-8-29都能成功转换为正确的date
时间是精确到小时分钟秒吗?
开发错误:在session中一个不同的对象有相同的id
org.springframework.orm.hibernate3.HibernateSystemException: a different object with the same identifier value was already associated with the session:
 [bgi.portal.pojo.NewsContent#95]; nested exception is org.hibernate.NonUniqueObjectException: 
a different object with the same identifier value was already associated with the session: [bgi.portal.pojo.NewsContent#95]研究spring中的hibernatetemplate的update,merge,saveorupdate方法
如果我们在这里使用了update(object)官方文档
(描述更新持久化实例,结合当前Hibernate的Session)
既然这里说道了session,种种情况就会显示出来了,比如错误:在session中一个不同的对象有相同的id
这个问题是怎么产生的呢?这种问题最多见于在更新实体时,首先取得一个对象比如:getUser()获取一个用户的信息
显示在页面上,这时user对象变为一个游离对象,然后在new user(),把修改过后的信息传给getUser()对象获得的对象user中去,
然后绑定在我们service中的一个方法中,这时服务层中产生的session会发现有两个id,但是又是不同实体。
如何解决了? 
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
抽象路由数据源通过路由机制基于一个key值来与不同的目标数据源通信获取数据库连接。
后者通常(但不一定)决定通过一些线程绑定上下文事务。
它的抽象方法:
protected abstract Object determineCurrentLookupKey()
之类继承他,重写该方法,解释该方法如下:
定义当前查询的键值,这通常是实施检查线程绑定的事务上下文
允许任意的键。返回的键需要匹配到已经存储好的键的类型,通过 resolveSpecifiedLookupKey(java.lang.Object)
方法可以解决。
(如下代码:
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;public class DynamicDataSource extends AbstractRoutingDataSource {
 protected Object determineCurrentLookupKey() {
  return CustomerContextHolder.getCustomerType();
 }
}/**
 * 设置上下文环境和获得上下文环境
 * @author tangxin
 *
 */
public class CustomerContextHolder {
 @SuppressWarnings("rawtypes")
 private static final ThreadLocal contextHolder = new ThreadLocal(); @SuppressWarnings("unchecked")
 public static void setCustomerType(String customerType) {
  contextHolder.set(customerType);
 } public static String getCustomerType() {
  return (String) contextHolder.get();
 } public static void clearCustomerType() {
  contextHolder.remove();
 }
})
public void setDefaultTargetDataSource(Object defaultTargetDataSource)
为动态数据源设置默认的数据源。
如果有的话,这个映射的值也可以成为一个一致的数据源实例或者一个数据源名称的字符串(要通过DataSourceLookup解决)
如果没有为目标数据源targetDataSources匹配方法determineCurrentLookupKey()设置当前的查询键,那么这个默认的数据源就会匹配到
方法determineCurrentLookupKey()中设置的当前查询的键(xml代码如下:
<!--  公共部分的数据源 -->
 <bean id="parentDataSource"
  class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
  <property name="username" value="root"></property>
  <property name="password" value="root"></property>
 </bean><!-- 中文数据库 -->
 <bean id="dataSource_zh" parent="parentDataSource">
  <property name="url"
   value="jdbc:mysql://localhost:3306/portal?useUnicode=true&characterEncoding=UTF-8"></property>
 </bean><!-- 英文数据库 -->
 <bean id="dataSource_en" parent="parentDataSource">
  <property name="url"
   value="jdbc:mysql://localhost:3306/portal_en?useUnicode=true&characterEncoding=UTF-8"></property>
 </bean>
<!-- 动态数据源 -->
 <bean id="dataSource" class="bgi.portal.datasource.DynamicDataSource">
  <property name="targetDataSources">
   <map key-type="java.lang.String">
    <entry key="portal_en" value-ref="dataSource_en" />
   </map>
  </property>
  <property name="defaultTargetDataSource" ref="dataSource_zh" />
 </bean>
) 
java 不同位置读取classpath中的文件返回的类型不同
这里指的不同位置比如:在一个类中的main方法,可能返回的值为BufferedInputStream
,但是当类在某个类中时,返回的可能是ByteArrayInputStream
如:
 public static void main(String[] args) throws IOException {
  Properties properties = new Properties();
  InputStream  inputStream = (BufferedInputStream) ChangeDataBaseAction.class.getClassLoader().getResourceAsStream("database.properties");
  properties.load(inputStream);
  System.out.println(properties.get("database.default_datasource"));
  
 }这段代码在main函数中可以运行,但是在某个类中运行就不行了。
public class ChangeDataBaseAction extends ActionSupport implements SessionAware{
public String changeBase_go(){
  
  Properties properties = new Properties();
  //这里如果返回为BufferedInputStream就会报错,所以入口不一样获取资源文件返回的类型也不一样
  ByteArrayInputStream  inputStream = (ByteArrayInputStream) this.getClass().getClassLoader().getResourceAsStream("database.properties");
  try {
   properties.load(inputStream);
  } catch (IOException e1) {
   // TODO Auto-generated catch block
   e1.printStackTrace();
  }
 }
} 
突然发现自己一个很笨的做法,既然struts2中的做编辑操作时有些没有被编辑的实体属性被默认设置成了空,
说明一点,要么在前台设置hidden隐藏表单域来set值,要么在后台根据id查询,其实想了一下都差不多,
要么设置隐藏表单域然后直接在业务层中传入实体保存,要么根据action中传入的实体的id查询该对象,
因为编辑的时候有id嘛。我总结了下还是重新查下实体好些,虽然这样代码多些但是便于调试,虽然当不用再查询
该对象时如果对象中还有其他对象,hibernate和struts2将默认设置很多对象之间的关系,但是多写些代码让你自己
更能了解你的业务和里面的关系。我觉得多写也可以。其实写很多隐藏表单域也蛮烦躁的。 
web+ssh2开发常用代码
//设置用户更新状态
<input name="userInfo.isLastUpdate" type="radio" id="isLastUpdate1" value="1" <c:if test="${userInfo.isLastUpdate == 1}">checked="checked"</c:if> />
<input name="userInfo.isLastUpdate" type="radio" id="isLastUpdate2" value="2" <c:if test="${userInfo.isLastUpdate == 2}">checked="checked"</c:if> />mysql在hbm.xml文件中的主键生成方式
<id name="id" type="java.lang.Integer">
   <column name="id" />
   <generator class="native" />
</id>比如实体新闻分类newsCary和新闻内容newsContent 他们的关系一对多
xml配置关系
在NewsCary.hbm.xml中
<set name="newsContents" inverse="false" fetch="join" lazy="true" cascade="all">
   <key>
    <column name="newscary_id" /><!--外键-->
   </key>
   <one-to-many class="bgi.portal.pojo.NewsContent"/>
</set>
在NewsContent.hbm.xml中
<many-to-one name="newsCary" class="bgi.portal.pojo.NewsCary" fetch="join">
   <column name="newscary_id" /><!--外键-->
</many-to-one>
在jsp中新闻内容绑定新闻类别代码:
<select name="newsContent.newsCary.id" id="cid" style="width: 200px;">
 <s:iterator value="newsCaryList">
  <option value="<s:property value="id"/>"
   <s:if test="newsContent.newsCary.id == id">selected="selected"</s:if>>
   <s:property value="title" />
  </option>
 </s:iterator>        
</select> 
 
java.io.Serializable 有什么作用?
一个java文件为什么只能有一个public class
 
 
新闻中心(功能列表)
1.置顶新闻内容。(在添加新闻内容或者编辑新闻内容时,把新闻内容指定排到第一位。可以最多置顶4条新闻内容)
 实现方式:在新闻内容实体中添加字段top1(注意:这里数据库可以是top,但是如果要使用struts标签的话,实体类中的字段名指定为top1
    因为struts s:if标签中使用top时会报错,所以这里在用el表达式取的时候请用top1取)
    添加字段top1为Integer型,top1=1表示置顶,top1=0表示未置顶,查询的时候使用sql的指定字段查询 
新闻置顶功能top1默认设置为0 防止导入历史数据出现问题
删除重大项目一级类别:
 第一种情况:
  如果一级类别下有二级类别
  首先要删除一级类别的图标
  然后如果一级类别下有二级类别就要删除所有二级类别的图标
  因为只定了二级类别,所有二级类别下就是内容列表了,则要删除每个二级类别下所有内容列表中的图标
 第二种情况:
  如果一级类别下有内容列表,则没有二级类别了。
  首先删除一级类别下的图标,然后删除一级类别下所有内容图标
 
 struts2 private String srcContentType;// 上传图标的src类型
// IE8中的pjpeg与safari的jpeg是一样的,但是必须都判断,不然无法兼容项目路径:D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\portal_admin
select id,title,newscary_id from newscontent where title like '%“联姻”奥尔胡斯大学%'
select * from newscontent where id = '7289'; 
select count(*) from newscontent;
select id,content from newscontent where content like '%data/attachment/image%'  and id=7291;
update newscontent set  content = replace(content,' /data/attachment/image', 'a/data/attachment/image') where id = 7291;
select id,content from newscontent where content like '%data/attachment/image%'  and id=7291;
update newscontent set  content = replace(content,' /test/data/attachment/image', '/data/attachment/image') where id = 7291;
update newscontent set  content = replace(content,'fasfasfasfa', '<p style="text-align: center"><a target="_blank" href="/data/attachment/image/IMG_0415-.jpg"><img height="170" width="256" border="0" alt="" src="/data/attachment/image/IMG_0415-.jpg" /></a> <a target="_blank" href="/data/attachment/image/IMG_0437-.jpg"><img height="170" width="255" border="0" alt="" src="/data/attachment/image/IMG_0437-.jpg" /></a></p>') where id = 7291;
select id,content from newscontent where    id=7291;
update newscontent set  content = replace(content,' src=\"/data/attachment/image', '') where id = 7291;
update newscontent set  content = replace(content,'src=\"/data/attachment/image', 'src=\"/portal_admin/data/attachment/image') 
insert into newscontent(title,newscary_id,key_words,content,author,source,hits,active,adate,is_last_update,created_date,top) 
insert into 1newscontent(title,newscary_id,key_words,content,author,source,hits,active,adate,is_last_update,created_date,top) select title,newscary_id,key_words,content,author,source,hits,active,adate,is_last_update,created_date,top  from 1newscontent where title like '%召开“运筹帷幄%';
select id,title,newscary_id,key_words,content,author,source,hits,active,adate,is_last_update,created_date,top  from 1newscontent where title like '%《自然》杂志就基因的创新人才模式发表社论%'; 
 
 
select * from newscontent where id = 7327;
update newscontent set  content = replace(content,' href=\"/data/attachment/image', 'href=\"/Portal/data/attachment/image') select newscary_id,adate, id,title,content from newscontent where newscary_id = 1  and title like '%在生物领域大显身手%'; 
 
 
 
 
/Portal/data/attachment/image/DSC_0015_调整.jpg
图片设置 400 268
 
//快速判断是否为一个完全的url
boolean flag = false;
  String url = "http://www.wallss.cn/attachments//day_090328/20090328_49669970ff2e6de08abfNOAoAhHhA05B-6515.jpg";
  //快速判断是否为一个完全的url
  // do a fast, simple check first
  int colonPos;
  colonPos = url.indexOf(":");
  if (colonPos == -1){
   System.out.println(colonPos);
   flag =  false;
  }else{
   flag = true;
  }
  System.out.println(flag);Console: true
//jakarta-taglibs-standard-1.1.2-src.zip 写法
boolean flag = false;
  String url = "head.html";
  //快速判断是否为一个完全的url
  // do a fast, simple check first
  int colonPos;
  if ((colonPos = url.indexOf(":")) == -1){
   System.out.println(colonPos);
   flag =  false;
  }
  System.out.println(flag);Console:  -1
false 
js设为首页;
方法二:<a title="设为首页" οnclick="this.style.behavior='url(#default#homepage)';this.setHomePage('');" href="javascript:;">设为首页</a>
</p> 
<!--    fckeditor配置开始 -->
  <display-name>FCKeditor Test Application</display-name>
  <servlet>
    <servlet-name>Connector</servlet-name>
    <servlet-class>com.fredck.FCKeditor.connector.ConnectorServlet</servlet-class>
    <init-param>
      <param-name>baseDir</param-name>
      <param-value>/UserFiles/</param-value>
    </init-param>
    <init-param>
      <param-name>debug</param-name>
      <param-value>true</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet>
    <servlet-name>SimpleUploader</servlet-name>
    <servlet-class>com.fredck.FCKeditor.uploader.SimpleUploaderServlet</servlet-class>
    <init-param>
      <param-name>baseDir</param-name>
      <param-value>/UserFiles/</param-value>
    </init-param>
    <init-param>
      <param-name>debug</param-name>
      <param-value>true</param-value>
    </init-param>
    <init-param>
      <param-name>enabled</param-name>
      <param-value>true</param-value>
    </init-param>
    <init-param>
      <param-name>AllowedExtensionsFile</param-name>
      <param-value></param-value>
    </init-param>
    <init-param>
      <param-name>DeniedExtensionsFile</param-name>
      <param-value>php|php3|php5|phtml|asp|aspx|ascx|jsp|cfm|cfc|pl|bat|exe|dll|reg|cgi</param-value>
    </init-param>
    <init-param>
      <param-name>AllowedExtensionsImage</param-name>
      <param-value>jpg|gif|jpeg|png|bmp</param-value>
    </init-param>
    <init-param>
      <param-name>DeniedExtensionsImage</param-name>
      <param-value></param-value>
    </init-param>
    <init-param>
      <param-name>AllowedExtensionsFlash</param-name>
      <param-value>swf|fla</param-value>
    </init-param>
    <init-param>
      <param-name>DeniedExtensionsFlash</param-name>
      <param-value></param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Connector</servlet-name>
    <url-pattern>/FCKeditor/editor/filemanager/browser/default/connectors/jsp/connector</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>SimpleUploader</servlet-name>
    <url-pattern>/FCKeditor/editor/filemanager/upload/simpleuploader</url-pattern>
  </servlet-mapping>
<!--     fckeditor配置结束 -->INSERT /*+ APPEND */ INTO calls (call_id, call_date, emp_id, call_type, details) SELECT call_id, call_date, emp_id, call_type, details FROM calls_external;