About neohope

一直在努力,还没想过要放弃...

struts2返回类型

Chain:
Action响应链,用于多个Action处理一次请求,
后面的Action可以访问前面的Action,不要过度使用

Dispatcher:
网络资源整合,如返回JSP页面,默认

FreeMarker:
用于FreeMarker整合

HttpHeader:
控制特定的HTTP行为

Redirect:
重定向到网络资源

Redirect Action:
重定向到另一个Action映射

Stream:
用于向浏览器提供输入流,一般用于文件下载

Velocity:
用于Velocity整合

XSL:
用于XML/XSLT整合

PlainText:
用于显示页面的原始内容

Tiles:
用于Tiles整合

MyEclipe中Java工程手动增加Maven支持

1修改文件.project

<buildSpec>
	<buildCommand>
		<name>org.maven.ide.eclipse.maven2Builder</name>
		<arguments>
		</arguments>
	</buildCommand>
</buildSpec>
<natures>
	<nature>org.maven.ide.eclipse.maven2Nature</nature>
</natures>

2.修改文件.classpath

<classpath>
	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
</classpath>

3.新增文件pom.xml

<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&#93;
  <modelVersion>4.0.0</modelVersion>

  <groupId>groupId</groupId>
  <artifactId>artifactId</artifactId>
  <version>1.0</version>
  <name>name</name>
 
  <dependencies>
  </dependencies>

  <build>
      <plugins>
      </plugins>
  </build>  
</project>

mongrel.rb

使用Redmin1.3.2时,用命令行可以启动,但使用mongrel_service-0.4.0启动后会发生重定向
只需要将mongrel.rb拷贝到redmine-1.3.2\config\initializers下面就好了

mongrel.rb

if ['2.3.8', '2.3.9', '2.3.10', '2.3.11', '2.3.14'].include?(Rails.version) && Gem.available?('mongrel', '~>1.1.5') && self.class.const_defined?(:Mongrel)
  
  # Pulled right from latest rack. Old looked like this in 1.1.0 version.
  #
  # def [](k)
  # super(@names[k] ||= @names[k.downcase])
  # end
  #
  module Rack
    module Utils
      class HeaderHash < Hash
        def [](k)
          super(@names[k]) if @names[k]
          super(@names[k.downcase])
        end
      end
    end
  end
  
  # Code pulled from the ticket above.
  #
  class Mongrel::CGIWrapper
    def header_with_rails_fix(options = 'text/html')
      @head['cookie'] = options.delete('cookie').flatten.map { |v| v.sub(/^\n/,'') } if options.class != String and options['cookie']
      header_without_rails_fix(options)
    end
    alias_method_chain :header, :rails_fix
  end
  
  # Pulled right from 2.3.8 ActionPack. Simple diff was
  #
  # if headers.include?('Set-Cookie')
  # headers['cookie'] = headers.delete('Set-Cookie').split("\n")
  # end
  #
  # to
  #
  # if headers['Set-Cookie']
  # headers['cookie'] = headers.delete('Set-Cookie').split("\n")
  # end
  #
  module ActionController
    class CGIHandler
      def self.dispatch_cgi(app, cgi, out = $stdout)
        env = cgi.__send__(:env_table)
        env.delete "HTTP_CONTENT_LENGTH"
        cgi.stdinput.extend ProperStream
        env["SCRIPT_NAME"] = "" if env["SCRIPT_NAME"] == "/"
        env.update({
          "rack.version" => [0,1],
          "rack.input" => cgi.stdinput,
          "rack.errors" => $stderr,
          "rack.multithread" => false,
          "rack.multiprocess" => true,
          "rack.run_once" => false,
          "rack.url_scheme" => ["yes", "on", "1"].include?(env["HTTPS"]) ? "https" : "http"
        })
        env["QUERY_STRING"] ||= ""
        env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
        env["REQUEST_PATH"] ||= "/"
        env.delete "PATH_INFO" if env["PATH_INFO"] == ""
        status, headers, body = app.call(env)
        begin
          out.binmode if out.respond_to?(:binmode)
          out.sync = false if out.respond_to?(:sync=)
          headers['Status'] = status.to_s
          if headers['Set-Cookie']
            headers['cookie'] = headers.delete('Set-Cookie').split("\n")
          end
          out.write(cgi.header(headers))
          body.each { |part|
            out.write part
            out.flush if out.respond_to?(:flush)
          }
        ensure
          body.close if body.respond_to?(:close)
        end
      end
    end
  end
end

SQL查询100到200行

--SQL Server
--top
select top 100 * from table
where id is not in(select top 100 id from table)
--row_number()
select r.*, row_number() over(order by id desc) as r from table where r>100 and r<=200


--MySQL
--limit
select * from  table limit 100,200;


--Oracle
--rownum
select * from (select rownum r,t.* from table t) where r>100 and r<=200;

SQL获取自增字段的值

数据插入后,如何获取自增字段的数值呢?可以用下面的方法
(建议进行事务控制)

--SQL Server
--当前会话,当前作用域
select SCOPE_IDENTITY() as id
--当前会话,不限定作用域
select @@identity as id
--指定表,不限定会话和作用域
select IDENT_CURRENT ('table_name')


--MySQL
--当前会话
SELECT LAST_INSERT_ID();
select @@IDENTITY as id


--Oracle
--当前会话
select seq_name.currval from dual

搭建Redmine

1.下载Ruby1.87及DevKit,解压,并将两个bin目录加入到PATH
http://rubyinstaller.org/downloads/

2.下载RubyGems 1.3.7,并安装

ruby setup.rb

3.安装gem
1)安装Rails 2.3.14

gem install rails -v=2.3.14 --include-dependencies

2)安装rake

gem install rake --include-dependencies

3)安装rack

gem install rack

4)安装mysql插件

gem install mysql

5)安装rdoc

gem install rdoc

6)安装i18n

gem install i18n

如果网速很差,可以把gem下载到本地后再安装,比如:

gem install i18n -l

4.配置数据库
1)拷贝dll
将mysql安装目录下的libmysql.dll拷贝到ruby路径
如果你的libmysql.dll版本高于5.1.3的话请用这个
http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/libmySQL.dll

2)配置数据库
下载并解压redmine-1.3.2
拷贝database.yml.example为database.yml,将production小节配置好

3)创建数据库

rake generate_session_store
rake db:migrate RAILS_ENV="production"

5.测试

ruby script/server -e production
#访问http://localhost:3000/
#用户名:admin
#密码:admin

6.配置email
拷贝configuration.yml.example为configuration.yml,
修改smtp配置,重启服务器即可

7.安装服务
1)安装gem

gem install mongrel_service

2)安装服务

mongrel_rails service::install -N Redmine -c D:\Ruby\redmine-1.3.2 -p 3000 -e production

3)设置服务依赖

sc config Redmine depend= MySQL start= auto

4)将mongrel.rb拷贝到redmin/config/initializers
mongrel.rb在github上有很多版本,但要自己改一下代码,来适应自己的rails版本

搭建Mantis

1.安装apache 2.2.x

2.配置apache端口
httpd.conf

Listen 8000

3.安装php5
需要模块:MySQL,SMTP,GD2

4.配置php
httpd.conf

AddType application/x-httpd-php .php .phtml .php3 .php4

5.解压mantis

6.配置mantis虚拟目录
httpd.conf

Alias /Mantis D:/mantisbt

<Directory "D:/mantisbt"]
        Options Indexes
        AllowOverride None
        Order allow,deny
        Allow from all
</Directory>

DirectoryIndex index.html index.php index.perl

7.安装mysql

8.新建用户,数据库,并为用户分配权限

9.首次访问mantis,按提示安装数据库,主要端口及大小写
http://127.0.0.1:8000/Mantis/login_page.php

10.首次登陆mantis,修改超级用户密码
http://127.0.0.1:8000/Mantis/login_page.php
用户名:administrator
密码:root

11.设置mantis语言
config_defaults_inc.php

$g_default_language  = 'chinese_simplified';

12.配置mantis邮件
config_defaults_inc.php

$g_smtp_host = "smtp服务器地址";
$g_smtp_username = '用户名';
$g_smtp_password = '密码';

13.配置mantis文件上传
config_defaults_inc.php

$g_allow_file_upload	= ON;
$g_file_upload_method	= DISK;

14.配置mantis图形插件,这里很麻烦,大体步骤如下
1)安装mantis报表插件
2)安装JpGraph,配置路径及字体,但插件配置中没有simsun字体
3)修改mantis代码,全局搜素,在出现verasans的地方,相应增加simsun,好像是三处
4)修改JpGraph,在处理simsun字体的时候,不用做转码,直接返回就好啦
5)去插件管理的地方,选择simsun
6)刷新即可

hl7 v2在socket通讯中应该注意的问题

1.hl7 v2在socket通讯时,是需要有起始及结束字符的
起始字符为0x0b
结束字符为0x1c 0x0d

2.正确处理换行
要将\r\n改为\r(0x0d)
单独的\n也替换为\r(0x0d)

3.同一socket收发信息,可以用msgid作为区分

4.因为utf-8的通用性及其编码规则比较适合网络传输,所以可以采用utf-8编码