guanxf

          我的博客:http://blog.sina.com.cn/17learning

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            71 隨筆 :: 1 文章 :: 41 評(píng)論 :: 0 Trackbacks

          2013年5月19日 #


          createTree(1, orgNodeTree, sameOrgNodes, 0);


          @NoArgsConstructor
          @AllArgsConstructor
          @Getter
          @Setter
          public class NodeTree {
          private String pName;
          private String name;
          private int level;
          private List<NodeTree> children;
          }

          private void createTree(int leave, int ind, Map<String, NodeTree> pIndexNodeNameMap, List<NodeVo> childNodes) {
          Map<String, NodeTree> cIndexNodeNameMap = new HashMap();
          //構(gòu)建樹
          int treeNo = pIndexNodeNameMap.size();
          if (treeNo == 0) {
          return;
          }
          int group = 0;
          for (int i = ind; i < childNodes.size(); i++) {
          NodeVo node = childNodes.get(i);
          long index = node.getId() % treeNo;
          NodeTree pNode = pIndexNodeNameMap.get(index + "");
          List<NodeTree> children = pNode.getChildren();
          if (CollectionUtils.isEmpty(children)) {
          children = new ArrayList();
          }
          if (children.size() > 2) {
          leave++;
          createTree(leave, i, cIndexNodeNameMap, childNodes);
          break;
          } else {
          NodeTree child = new NodeTree();
          child.setLevel(leave);
          child.setPName(pNode.getName());
          child.setName(node.getNodeName());
          children.add(child);
          pNode.setChildren(children);
          cIndexNodeNameMap.put(group + "", child);
          group++;
          }
          }
          }


          private boolean createTree(int level, List<NodeTree> parentNodes, List<NodeVo> childNodes, int beginIndex) {
          //構(gòu)建樹
          List<NodeTree> nextLevelNodes = new ArrayList<>();
          for (int i = beginIndex; i < childNodes.size(); i++) {
          int parentCount = 1;
          for (NodeTree pNode : parentNodes) {
          List<NodeTree> children = pNode.getChildren();
          if (CollectionUtils.isEmpty(children)) {
          children = new ArrayList();
          pNode.setChildren(children);
          }
          if (children.size() >= 3) {
          if(parentCount >= parentNodes.size()){
          return createTree(++level, nextLevelNodes, childNodes, beginIndex);
          }
          } else {
          if (beginIndex >= childNodes.size()) {
          return true;
          }
          NodeTree child = new NodeTree();
          child.setLevel(level);
          child.setPName(pNode.getName());
          NodeVo node = childNodes.get(beginIndex);
          child.setName(node.getNodeName());
          pNode.getChildren().add(child);
          nextLevelNodes.add(child);
          beginIndex++;
          }
          parentCount++;
          }
          }
          return true;
          }
          posted @ 2020-09-07 09:56 管先飛 閱讀(259) | 評(píng)論 (0)編輯 收藏

          執(zhí)行命名:
          git pull github master --allow-unrelated-histories

          執(zhí)行結(jié)果如下:

          E:\WorkSpace\workspaceJ2ee\abocode\jfaster>git pull github master --allow-unrelated-histories
          remote: Counting objects: 3, done.
          remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 3
          Unpacking objects: 100% (3/3), done.
          From https://github.com/abocode/jfaster
           * branch            master     -> FETCH_HEAD
           * [new branch]      master     -> github/master
          Merge made by the 'recursive' strategy.
           .gitattributes | 3 +++
           1 file changed, 3 insertions(+)
           create mode 100644 .gitattributes
          posted @ 2018-05-20 12:30 管先飛 閱讀(322) | 評(píng)論 (0)編輯 收藏

          進(jìn)入“控制面板”——“用戶賬戶”-憑據(jù)管理器——windows憑據(jù)

          找到了git的用戶名密碼。修改正確后ok

          posted @ 2018-05-20 12:29 管先飛 閱讀(272) | 評(píng)論 (0)編輯 收藏

          元注解:

            元注解的作用就是負(fù)責(zé)注解其他注解。Java5.0定義了4個(gè)標(biāo)準(zhǔn)的meta-annotation類型,它們被用來提供對(duì)其它 annotation類型作說明。Java5.0定義的元注解:
              1.@Target,
              2.@Retention,
              3.@Documented,
              4.@Inherited

            這些類型和它們所支持的類在java.lang.annotation包中可以找到。下面我們看一下每個(gè)元注解的作用和相應(yīng)分參數(shù)的使用說明。
          以下為一個(gè)簡單場(chǎng)景的應(yīng)用:
           1.定義注解:
             
          @Target(TYPE)
          @Retention(RUNTIME)
          public @interface Table {
          /**
          * (Optional) The name of the table.
          * <p/>
          * Defaults to the entity name.
          */
          String name() default "";
          }
          @Target({METHOD, FIELD})
          @Retention(RUNTIME)
          public @interface Column {

          /**
          * (Optional) The name of the column. Defaults to
          * the property or field name.
          */
          String name() default "";
          }
          2、定義實(shí)體類:
            

          @Table(name = "t_s_user")
          public class User {
          @Column(name="name")
          private String name;

          @Column(name="pwd")
          private String pwd;

          public String getName() {
          return name;
          }

          public void setName(String name) {
          this.name = name;
          }

          public String getPwd() {
          return pwd;
          }

          public void setPwd(String pwd) {
          this.pwd = pwd;
          }
          }

          3、運(yùn)行:

          public static void print() {
          System.out.println("table's name" + User.class.getAnnotation(Table.class).name());
          Field[] fields = User.class.getDeclaredFields();
          for (int i = 0; i < fields.length; i++) {
          Field field = fields[i];
          System.out.println("field's type:" + field.getType().getName());
          System.out.println("field's columnName:" + field.getAnnotation(Column.class).name());
          }
          }

          關(guān)于注解的詳細(xì)介紹:http://www.cnblogs.com/peida/archive/2013/04/24/3036689.html
          posted @ 2016-08-18 20:42 管先飛 閱讀(2845) | 評(píng)論 (0)編輯 收藏

          1.選擇:File->project structure->libraries

          2.左上角選擇添加,選擇添加java(還提供了添加maven項(xiàng)目),然后選擇所需要的目錄:

          3.idea 會(huì)提示選擇添加什么類型的文件,我們是單純的文件,所以選擇classes

             

           
          posted @ 2016-04-29 15:42 管先飛 閱讀(1706) | 評(píng)論 (0)編輯 收藏

          nginx 反向代理到 apache
          server {
                  listen       80;
                  server_name  app.haeee.com;
          index index.html index.htm index.php;
             root /alidata/www/movie-app;
               error_page 404 500 502 503 504 http://app.haeee.com; 
          location ~ .*\.(php|php5)?$
          {
          #fastcgi_pass  unix:/tmp/php-cgi.sock;
          fastcgi_pass  127.0.0.1:9000;
          fastcgi_index index.php;
          include fastcgi.conf;
          }
          location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
          {
          expires 30d;
          }
          location ~ .*\.(js|css)?$
          {
          expires 1h;
          }
          #偽靜態(tài)規(guī)則
          #include /alidata/server/nginx/conf/rewrite/phpwind.conf;
          access_log  /alidata/log/nginx/access/movie-app.log;
          }

          nginx 反向代理到 tomcat
          server {
              listen   80;
              server_name  hulasou.com www.hulasou.com;
          index index.html index.htm index.jsp;
          #location ~ .*\.(jsp)?$
          location /{      
          index index.jsp;
                  proxy_pass http://localhost:8181;
          }
          #偽靜態(tài)規(guī)則
          include /alidata/server/nginx/conf/rewrite/uuxiaohua.conf;
          access_log  /alidata/log/nginx/access/uuxiaohua.log;
          }
          posted @ 2016-01-19 17:46 管先飛 閱讀(411) | 評(píng)論 (0)編輯 收藏

          1、修改啟動(dòng)項(xiàng):
          @SpringBootApplication
          @ComponentScan
          @Import({DBConfiguration.class, ResourceConfiguration.class,AppConfiguration.class})
          public class Application extends SpringBootServletInitializer {
          @Override
          protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
          return application.sources(Application.class);
          }
          2、修改pom文件:
              修改packaging
              <packaging>war</packaging>
            加入打包到tomcat的配置:
          <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-tomcat</artifactId>
          <scope>provided</scope>
          </dependency>
          <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-legacy</artifactId>
          <version>1.0.2.RELEASE</version>
          </dependency>

          <dependency>
          <groupId>javax.servlet</groupId>
          <artifactId>javax.servlet-api</artifactId>
          <version>3.0.1</version>
          </dependency>
          <dependency>
          <groupId>javax.servlet</groupId>
          <artifactId>javax.servlet-api</artifactId>
          <version>3.0.1</version>
          </dependency>

          <dependency>
          <groupId>commons-fileupload</groupId>
          <artifactId>commons-fileupload</artifactId>
          <version>1.3.1</version>
          </dependency>

          3、如果不需要JMX在application.properties文件中加入配置項(xiàng):
          endpoints.jmx.uniqueNames=true
          或者直接關(guān)閉:
           endpoints.jmx.enabled=false
          posted @ 2016-01-14 17:21 管先飛 閱讀(6565) | 評(píng)論 (1)編輯 收藏

          spring data 系列一直是開發(fā)者追捧的熱潮,而官方并未出spring data  jdbc,國外一個(gè)開發(fā)者讓我們看到了福音,文檔如下供大家共同學(xué)習(xí)。

          Build Status Maven Central

          Spring Data JDBC generic DAO implementation

          The purpose of this project is to provide generic, lightweight and easy to use DAO implementation for relational databases based on JdbcTemplate from Spring framework, compatible with Spring Data umbrella of projects.

          Design objectives

          • Lightweight, fast and low-overhead. Only a handful of classes, no XML, annotations, reflection
          • This is not full-blown ORM. No relationship handling, lazy loading, dirty checking, caching
          • CRUD implemented in seconds
          • For small applications where JPA is an overkill
          • Use when simplicity is needed or when future migration e.g. to JPA is considered
          • Minimalistic support for database dialect differences (e.g. transparent paging of results)

          Features

          Each DAO provides built-in support for:

          • Mapping to/from domain objects through RowMapper abstraction
          • Generated and user-defined primary keys
          • Extracting generated key
          • Compound (multi-column) primary keys
          • Immutable domain objects
          • Paging (requesting subset of results)
          • Sorting over several columns (database agnostic)
          • Optional support for many-to-one relationships
          • Supported databases (continuously tested):
            • MySQL
            • PostgreSQL
            • H2
            • HSQLDB
            • Derby
            • MS SQL Server (2008, 2012)
            • Oracle 10g / 11g (9i should work too)
            • ...and most likely many others
          • Easily extendable to other database dialects via SqlGenerator class.
          • Easy retrieval of records by ID

          API

          Compatible with Spring Data PagingAndSortingRepository abstraction, all these methods are implemented for you:

          public interface PagingAndSortingRepository<T, ID extends Serializable> extends CrudRepository<T, ID> {
           T  save(T entity);
          Iterable<T> save(Iterable<? extends T> entities);
           T  findOne(ID id);
          boolean exists(ID id);
          Iterable<T> findAll();
             long count();
             void delete(ID id);
             void delete(T entity);
             void delete(Iterable<? extends T> entities);
             void deleteAll();
          Iterable<T> findAll(Sort sort);
          Page<T> findAll(Pageable pageable);
          Iterable<T> findAll(Iterable<ID> ids);
          }
          

          Pageable and Sort parameters are also fully supported, which means you get paging and sorting by arbitrary properties for free. For example say you have userRepository extending PagingAndSortingRepository<User, String> interface (implemented for you by the library) and you request 5th page of USERS table, 10 per page, after applying some sorting:

          Page<User> page = userRepository.findAll(
          new PageRequest(
          5, 10, 
          new Sort(
          new Order(DESC, "reputation"), 
          new Order(ASC, "user_name")
          )
          )
          );
          

          Spring Data JDBC repository library will translate this call into (PostgreSQL syntax):

          SELECT *
          FROM USERS
          ORDER BY reputation DESC, user_name ASC
          LIMIT 50 OFFSET 10
          

          ...or even (Derby syntax):

          SELECT * FROM (
          SELECT ROW_NUMBER() OVER () AS ROW_NUM, t.*
          FROM (
          SELECT * 
          FROM USERS 
          ORDER BY reputation DESC, user_name ASC
          ) AS t
          ) AS a 
          WHERE ROW_NUM BETWEEN 51 AND 60
          

          No matter which database you use, you'll get Page<User> object in return (you still have to provide RowMapper<User> yourself to translate from ResultSet to domain object). If you don't know Spring Data project yet, Page<T> is a wonderful abstraction, not only encapsulating List<T>, but also providing metadata such as total number of records, on which page we currently are, etc.

          Reasons to use

          • You consider migration to JPA or even some NoSQL database in the future.

            Since your code will rely only on methods defined in PagingAndSortingRepository and CrudRepository from Spring Data Commons umbrella project you are free to switch from JdbcRepository implementation (from this project) to: JpaRepository, MongoRepository, GemfireRepository or GraphRepository. They all implement the same common API. Of course don't expect that switching from JDBC to JPA or MongoDB will be as simple as switching imported JAR dependencies - but at least you minimize the impact by using same DAO API.

          • You need a fast, simple JDBC wrapper library. JPA or even MyBatis is an overkill

          • You want to have full control over generated SQL if needed

          • You want to work with objects, but don't need lazy loading, relationship handling, multi-level caching, dirty checking... You need CRUD and not much more

          • You want to by DRY

          • You are already using Spring or maybe even JdbcTemplate, but still feel like there is too much manual work

          • You have very few database tables

          Getting started

          For more examples and working code don't forget to examine project tests.

          Prerequisites

          Maven coordinates:

          <dependency>
          <groupId>com.nurkiewicz.jdbcrepository</groupId>
          <artifactId>jdbcrepository</artifactId>
          <version>0.4</version>
          </dependency>
          

          This project is available under maven central repository.

          Alternatively you can download source code as ZIP.


          In order to start your project must have DataSource bean present and transaction management enabled. Here is a minimal MySQL configuration:

          @EnableTransactionManagement
          @Configuration
          public class MinimalConfig {
          @Bean
          public PlatformTransactionManager transactionManager() {
          return new DataSourceTransactionManager(dataSource());
          }
          @Bean
          public DataSource dataSource() {
          MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
          ds.setUser("user");
          ds.setPassword("secret");
          ds.setDatabaseName("db_name");
          return ds;
          }
          }
          

          Entity with auto-generated key

          Say you have a following database table with auto-generated key (MySQL syntax):

          CREATE TABLE COMMENTS (
          id INT AUTO_INCREMENT,
          user_name varchar(256),
          contents varchar(1000),
          created_time TIMESTAMP NOT NULL,
          PRIMARY KEY (id)
          );
          

          First you need to create domain object User mapping to that table (just like in any other ORM):

          public class Comment implements Persistable<Integer> {
          private Integer id;
          private String userName;
          private String contents;
          private Date createdTime;
          @Override
          public Integer getId() {
          return id;
          }
          @Override
          public boolean isNew() {
          return id == null;
          }
          //getters/setters/constructors/...
          }
          

          Apart from standard Java boilerplate you should notice implementing Persistable<Integer> where Integer is the type of primary key. Persistable<T> is an interface coming from Spring Data project and it's the only requirement we place on your domain object.

          Finally we are ready to create our CommentRepository DAO:

          @Repository
          public class CommentRepository extends JdbcRepository<Comment, Integer> {
          public CommentRepository() {
          super(ROW_MAPPER, ROW_UNMAPPER, "COMMENTS");
          }
          public static final RowMapper<Comment> ROW_MAPPER = //see below
          private static final RowUnmapper<Comment> ROW_UNMAPPER = //see below
          @Override
          protected <S extends Comment> S postCreate(S entity, Number generatedId) {
          entity.setId(generatedId.intValue());
          return entity;
          }
          }
          

          First of all we use @Repository annotation to mark DAO bean. It enables persistence exception translation. Also such annotated beans are discovered by CLASSPATH scanning.

          As you can see we extend JdbcRepository<Comment, Integer> which is the central class of this library, providing implementations of all PagingAndSortingRepository methods. Its constructor has three required dependencies: RowMapper, RowUnmapper and table name. You may also provide ID column name, otherwise default "id" is used.

          If you ever used JdbcTemplate from Spring, you should be familiar with RowMapper interface. We need to somehow extract columns from ResultSet into an object. After all we don't want to work with raw JDBC results. It's quite straightforward:

          public static final RowMapper<Comment> ROW_MAPPER = new RowMapper<Comment>() {
          @Override
          public Comment mapRow(ResultSet rs, int rowNum) throws SQLException {
          return new Comment(
          rs.getInt("id"),
          rs.getString("user_name"),
          rs.getString("contents"),
          rs.getTimestamp("created_time")
          );
          }
          };
          

          RowUnmapper comes from this library and it's essentially the opposite of RowMapper: takes an object and turns it into a Map. This map is later used by the library to construct SQL CREATE/UPDATE queries:

          private static final RowUnmapper<Comment> ROW_UNMAPPER = new RowUnmapper<Comment>() {
          @Override
          public Map<String, Object> mapColumns(Comment comment) {
          Map<String, Object> mapping = new LinkedHashMap<String, Object>();
          mapping.put("id", comment.getId());
          mapping.put("user_name", comment.getUserName());
          mapping.put("contents", comment.getContents());
          mapping.put("created_time", new java.sql.Timestamp(comment.getCreatedTime().getTime()));
          return mapping;
          }
          };
          

          If you never update your database table (just reading some reference data inserted elsewhere) you may skip RowUnmapper parameter or use MissingRowUnmapper.

          Last piece of the puzzle is the postCreate() callback method which is called after an object was inserted. You can use it to retrieve generated primary key and update your domain object (or return new one if your domain objects are immutable). If you don't need it, just don't override postCreate().

          Check out JdbcRepositoryGeneratedKeyTest for a working code based on this example.

          By now you might have a feeling that, compared to JPA or Hibernate, there is quite a lot of manual work. However various JPA implementations and other ORM frameworks are notoriously known for introducing significant overhead and manifesting some learning curve. This tiny library intentionally leaves some responsibilities to the user in order to avoid complex mappings, reflection, annotations... all the implicitness that is not always desired.

          This project is not intending to replace mature and stable ORM frameworks. Instead it tries to fill in a niche between raw JDBC and ORM where simplicity and low overhead are key features.

          Entity with manually assigned key

          In this example we'll see how entities with user-defined primary keys are handled. Let's start from database model:

          CREATE TABLE USERS (
          user_name varchar(255),
          date_of_birth TIMESTAMP NOT NULL,
          enabled BIT(1) NOT NULL,
          PRIMARY KEY (user_name)
          );
          

          ...and User domain model:

          public class User implements Persistable<String> {
          private transient boolean persisted;
          private String userName;
          private Date dateOfBirth;
          private boolean enabled;
          @Override
          public String getId() {
          return userName;
          }
          @Override
          public boolean isNew() {
          return !persisted;
          }
          public void setPersisted(boolean persisted) {
          this.persisted = persisted;
          }
          //getters/setters/constructors/...
          }
          

          Notice that special persisted transient flag was added. Contract of [CrudRepository.save()](http://static.springsource.org/spring-data/data-commons/docs/current/api/org/springframework/data/repository/CrudRepository.html#save(S)) from Spring Data project requires that an entity knows whether it was already saved or not (isNew()) method - there are no separate create() and update() methods. Implementing isNew() is simple for auto-generated keys (see Comment above) but in this case we need an extra transient field. If you hate this workaround and you only insert data and never update, you'll get away with return true all the time from isNew().

          And finally our DAO, UserRepository bean:

          @Repository
          public class UserRepository extends JdbcRepository<User, String> {
          public UserRepository() {
          super(ROW_MAPPER, ROW_UNMAPPER, "USERS", "user_name");
          }
          public static final RowMapper<User> ROW_MAPPER = //...
          public static final RowUnmapper<User> ROW_UNMAPPER = //...
          @Override
          protected <S extends User> S postUpdate(S entity) {
          entity.setPersisted(true);
          return entity;
          }
          @Override
          protected <S extends User> S postCreate(S entity, Number generatedId) {
          entity.setPersisted(true);
          return entity;
          }
          }
          

          "USERS" and "user_name" parameters designate table name and primary key column name. I'll leave the details of mapper and unmapper (see source code). But please notice postUpdate() and postCreate() methods. They ensure that once object was persisted, persisted flag is set so that subsequent calls to save() will update existing entity rather than trying to reinsert it.

          Check out JdbcRepositoryManualKeyTest for a working code based on this example.

          Compound primary key

          We also support compound primary keys (primary keys consisting of several columns). Take this table as an example:

          CREATE TABLE BOARDING_PASS (
          flight_no VARCHAR(8) NOT NULL,
          seq_no INT NOT NULL,
          passenger VARCHAR(1000),
          seat CHAR(3),
          PRIMARY KEY (flight_no, seq_no)
          );
          

          I would like you to notice the type of primary key in Persistable<T>:

          public class BoardingPass implements Persistable<Object[]> {
          private transient boolean persisted;
          private String flightNo;
          private int seqNo;
          private String passenger;
          private String seat;
          @Override
          public Object[] getId() {
          return pk(flightNo, seqNo);
          }
          @Override
          public boolean isNew() {
          return !persisted;
          }
          //getters/setters/constructors/...
          }
          

          Unfortunately library does not support small, immutable value classes encapsulating all ID values in one object (like JPA does with @IdClass), so you have to live with Object[] array. Defining DAO class is similar to what we've already seen:

          public class BoardingPassRepository extends JdbcRepository<BoardingPass, Object[]> {
          public BoardingPassRepository() {
          this("BOARDING_PASS");
          }
          public BoardingPassRepository(String tableName) {
          super(MAPPER, UNMAPPER, new TableDescription(tableName, null, "flight_no", "seq_no")
          );
          }
          public static final RowMapper<BoardingPass> ROW_MAPPER = //...
          public static final RowUnmapper<BoardingPass> UNMAPPER = //...
          }
          

          Two things to notice: we extend JdbcRepository<BoardingPass, Object[]> and we provide two ID column names just as expected: "flight_no", "seq_no". We query such DAO by providing both flight_no and seq_no (necessarily in that order) values wrapped by Object[]:

          BoardingPass pass = boardingPassRepository.findOne(new Object[] {"FOO-1022", 42});
          

          No doubts, this is cumbersome in practice, so we provide tiny helper method which you can statically import:

          import static com.nurkiewicz.jdbcrepository.JdbcRepository.pk;
          //...
          BoardingPass foundFlight = boardingPassRepository.findOne(pk("FOO-1022", 42));
          

          Check out JdbcRepositoryCompoundPkTest for a working code based on this example.

          Transactions

          This library is completely orthogonal to transaction management. Every method of each repository requires running transaction and it's up to you to set it up. Typically you would place @Transactional on service layer (calling DAO beans). I don't recommend placing @Transactional over every DAO bean.

          Caching

          Spring Data JDBC repository library is not providing any caching abstraction or support. However adding @Cacheable layer on top of your DAOs or services using caching abstraction in Spring is quite straightforward. See also: @Cacheable overhead in Spring.

          Contributions

          ..are always welcome. Don't hesitate to submit bug reports and pull requests.

          Testing

          This library is continuously tested using Travis (Build Status). Test suite consists of 60+ distinct tests each run against 8 different databases: MySQL, PostgreSQL, H2, HSQLDB and Derby + MS SQL Server and Oracle tests not run as part of CI.

          When filling bug reports or submitting new features please try including supporting test cases. Each pull request is automatically tested on a separate branch.

          Building

          After forking the official repository building is as simple as running:

          $ mvn install
          

          You'll notice plenty of exceptions during JUnit test execution. This is normal. Some of the tests run against MySQL and PostgreSQL available only on Travis CI server. When these database servers are unavailable, whole test is simply skipped:

          Results :
          Tests run: 484, Failures: 0, Errors: 0, Skipped: 295
          

          Exception stack traces come from root AbstractIntegrationTest.

          Design

          Library consists of only a handful of classes, highlighted in the diagram below (source):

          UML diagram

          JdbcRepository is the most important class that implements all PagingAndSortingRepository methods. Each user repository has to extend this class. Also each such repository must at least implement RowMapper and RowUnmapper (only if you want to modify table data).

          SQL generation is delegated to SqlGenerator. PostgreSqlGenerator. and DerbySqlGenerator are provided for databases that don't work with standard generator.

          Changelog

          0.4.1

          0.4

          • Repackaged: com.blogspot.nurkiewicz -> com.nurkiewicz

          0.3.2

          • First version available in Maven central repository
          • Upgraded Spring Data Commons 1.6.1 -> 1.8.0

          0.3.1

          0.3

          0.2

          0.1

          License

          This project is released under version 2.0 of the Apache License (same as Spring framework).

          posted @ 2015-12-28 23:48 管先飛 閱讀(4106) | 評(píng)論 (2)編輯 收藏

          Idea是目前最好的開發(fā)工具,經(jīng)收集及整理如下常用快捷鍵: 
          一、常用快捷鍵:
           

               
            1.常用操作:
                 Ctrl+E,可以顯示最近編輯的文件列表
            Shift+Click可以關(guān)閉文件
            Ctrl+[或]可以跳到大括號(hào)的開頭結(jié)尾
            Ctrl+Shift+Backspace可以跳轉(zhuǎn)到上次編輯的地方
            Ctrl+F12,可以顯示當(dāng)前文件的結(jié)構(gòu)
            Ctrl+F7可以查詢當(dāng)前元素在當(dāng)前文件中的引用,然后按F3可以選擇
            Ctrl+N,可以快速打開類
            Ctrl+Shift+N,可以快速打開文件
            Alt+Q可以看到當(dāng)前方法的聲明
            Ctrl+W可以選擇單詞繼而語句繼而行繼而函數(shù)
            Alt+F1可以將正在編輯的元素在各個(gè)面板中定位
            Ctrl+P,可以顯示參數(shù)信息
            Ctrl+Shift+Insert可以選擇剪貼板內(nèi)容并插入
            Alt+Insert可以生成構(gòu)造器/Getter/Setter等
            Ctrl+Alt+V 可以引入變量。例如把括號(hào)內(nèi)的SQL賦成一個(gè)變量
            Ctrl+Alt+T可以把代碼包在一塊內(nèi),例如try/catch
            Alt+Up and Alt+Down可在方法間快速移動(dòng)

            2. 查詢快捷鍵
            CTRL+N 查找類
            CTRL+SHIFT+N 查找文件
            CTRL+SHIFT+ALT+N 查找類中的方法或變量
            CIRL+B 找變量的來源
            CTRL+ALT+B 找所有的子類
            CTRL+SHIFT+B 找變量的類
            CTRL+G 定位行
            CTRL+F 在當(dāng)前窗口查找文本
            CTRL+SHIFT+F 在指定窗口查找文本
            CTRL+R 在 當(dāng)前窗口替換文本
            CTRL+SHIFT+R 在指定窗口替換文本
            ALT+SHIFT+C 查找修改的文件
            CTRL+E 最近打開的文件
            F3 向下查找關(guān)鍵字出現(xiàn)位置
            SHIFT+F3 向上一個(gè)關(guān)鍵字出現(xiàn)位置
            F4 查找變量來源
            CTRL+ALT+F7 選中的字符查找工程出現(xiàn)的地方
            CTRL+SHIFT+O 彈出顯示查找內(nèi)容

            3. 自動(dòng)代碼
            ALT+回車 導(dǎo)入包,自動(dòng)修正
            CTRL+ALT+L 格式化代碼
            CTRL+ALT+I 自動(dòng)縮進(jìn)
            CTRL+ALT+O 優(yōu)化導(dǎo)入的類和包
            ALT+INSERT 生成代碼(如GET,SET方法,構(gòu)造函數(shù)等)
            CTRL+E 最近更改的代碼
            CTRL+SHIFT+SPACE 自動(dòng)補(bǔ)全代碼
            CTRL+空格 代碼提示
            CTRL+ALT+SPACE 類名或接口名提示
            CTRL+P 方法參數(shù)提示
            CTRL+J 自動(dòng)代碼
            CTRL+ALT+T 把選中的代碼放在 TRY{} IF{} ELSE{} 里

            4. 復(fù)制快捷方式
            CTRL+D 復(fù)制行
            CTRL+X 剪切,刪除行
            5. 其他快捷方式
            CIRL+U 大小寫切換
            CTRL+Z 倒退
            CTRL+SHIFT+Z 向前
            CTRL+ALT+F12 資源管理器打開文件夾
            ALT+F1 查找文件所在目錄位置
            SHIFT+ALT+INSERT 豎編輯模式
            CTRL+/ 注釋//
            CTRL+SHIFT+/ 注釋/*...*/
            CTRL+W 選中代碼,連續(xù)按會(huì)有其他效果
            CTRL+B 快速打開光標(biāo)處的類或方法
            ALT+ ←/→ 切換代碼視圖
            CTRL+ALT ←/→ 返回上次編輯的位置
            ALT+ ↑/↓ 在方法間快速移動(dòng)定位
            SHIFT+F6 重構(gòu)-重命名
            CTRL+H 顯示類結(jié)構(gòu)圖
            CTRL+Q 顯示注釋文檔
            ALT+1 快速打開或隱藏工程面板
            CTRL+SHIFT+UP/DOWN 代碼向上/下移動(dòng)。
            CTRL+UP/DOWN 光標(biāo)跳轉(zhuǎn)到第一行或最后一行下
            ESC 光標(biāo)返回編輯框
            SHIFT+ESC 光標(biāo)返回編輯框,關(guān)閉無用的窗口
            F1 幫助千萬別按,很卡!
            CTRL+F4 非常重要下班都用

          二、常用配置:
            1. IDEA內(nèi)存優(yōu)化
            因機(jī)器本身的配置而配置:
            \IntelliJ IDEA 8\bin\idea.exe.vmoptions
            -----------------------------------------
            -Xms64m
            -Xmx256m
            -XX:MaxPermSize=92m
            -ea
            -server
            -Dsun.awt.keepWorkingSetOnMinimize=true

          posted @ 2015-09-26 11:38 管先飛 閱讀(489) | 評(píng)論 (0)編輯 收藏

          1、編寫腳步:update.js
               /**
           * 時(shí)間對(duì)象的格式化;
           */
          Date.prototype.format = function(format) {
              /*
               * eg:format="YYYY-MM-dd hh:mm:ss";
               */
              var o = {
                  "M+" :this.getMonth() + 1, // month
                  "d+" :this.getDate(), // day
                  "h+" :this.getHours(), // hour
                  "m+" :this.getMinutes(), // minute
                  "s+" :this.getSeconds(), // second
                  "q+" :Math.floor((this.getMonth() + 3) / 3), // quarter
                  "S" :this.getMilliseconds()
              // millisecond
              }
           
              if (/(y+)/.test(format)) {
                  format = format.replace(RegExp.$1, (this.getFullYear() + "")
                          .substr(4 - RegExp.$1.length));
              }
           
              for ( var k in o) {
                  if (new RegExp("(" + k + ")").test(format)) {
                      format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k]
                              : ("00" + o[k]).substr(("" + o[k]).length));
                  }
              }
              return format;
          }
          var date =new Date();
          var createdate=date.format("yyyy-MM-dd hh:mm:ss");
          date.setMinutes(date.getMinutes()+5);
          var validtime=date.format("yyyy-MM-dd hh:mm:ss");
          db.UserOnlineInfo.update(
          {
            "uid" : "110000350"
          },
          {$set : {
            "uid" : "110000350", 
            "createtime" : createdate,
            "validtime" : validtime
          }});
          db.UserOnlineInfo.update(
          {
            "uid" : "110000351"
          },
          {$set : {
            "uid" : "110000351", 
            "createtime" : createdate,
            "validtime" : validtime
          }});

          2、編寫shell腳步:
           #/bin/bash
          echo "update mongod begin"
          cd /home/mongodb/mongodb-3.0.2/bin
          ./mongo  192.168.1.122:27108/YouLiao update.js;
          echo "update mongod success"

          3、 執(zhí)行腳本:
          /home/mongodb/mongodb-3.0.2/bin/mongo  192.168.1.122:27108/YouLiao /root/www/job/mongo-test/update.js

          備注:
          mongodb查詢、刪除類似

             
          posted @ 2015-09-22 19:25 管先飛 閱讀(3571) | 評(píng)論 (0)編輯 收藏

          Java多線程技術(shù)  --作者:楊帆    文章連接:http://express.ruanko.com/ruanko-express_6/webpage/tech4.html
           
          項(xiàng)目經(jīng)理:楊帆

          多線程編程一直是學(xué)員們比較頭痛和心虛的地方,因?yàn)榫€程執(zhí)行順序的不可預(yù)知性和調(diào)試時(shí)候的困難,讓不少人在面對(duì)多線程的情況下選擇了逃避,采用單線程的方式,其實(shí)只要我們對(duì)線程有了明確的認(rèn)識(shí),再加上java內(nèi)置的對(duì)多線程的天然支持,多線程編程不再是一道難以逾越的鴻溝。

          進(jìn)程、線程、并發(fā)執(zhí)行

          首先我們先來認(rèn)識(shí)一下進(jìn)程、線程、并發(fā)執(zhí)行的概念:

            一般來說,當(dāng)運(yùn)行一個(gè)應(yīng)用程序的時(shí)候,就啟動(dòng)了一個(gè)進(jìn)程,當(dāng)然有些會(huì)啟動(dòng)多個(gè)進(jìn)程。啟動(dòng)進(jìn)程的時(shí)候,操作系統(tǒng)會(huì)為進(jìn)程分配資源,其中最主要的資源是內(nèi)存空間,因?yàn)槌绦蚴窃趦?nèi)存中運(yùn)行的。

          在進(jìn)程中,有些程序流程塊是可以亂序執(zhí)行的,并且這個(gè)代碼塊可以同時(shí)被多次執(zhí)行。實(shí)際上,這樣的代碼塊就是線程體。線程是進(jìn)程中亂序執(zhí)行的代碼流程。當(dāng)多個(gè)線程同時(shí)運(yùn)行的時(shí)候,這樣的執(zhí)行模式成為并發(fā)執(zhí)行。

          下面我以一個(gè)日常生活中簡單的例子來說明進(jìn)程和線程之間的區(qū)別和聯(lián)系:

          雙向多車道道路圖

          這副圖是一個(gè)雙向多車道的道路圖,假如我們把整條道路看成是一個(gè)“進(jìn)程”的話,那么圖中由白色虛線分隔開來的各個(gè)車道就是進(jìn)程中的各個(gè)“線程”了。

          1. 這些線程(車道)共享了進(jìn)程(道路)的公共資源(土地資源)。
          2. 這些線程(車道)必須依賴于進(jìn)程(道路),也就是說,線程不能脫離于進(jìn)程而存在(就像離開了道路,車道也就沒有意義了)。
          3. 這些線程(車道)之間可以并發(fā)執(zhí)行(各個(gè)車道你走你的,我走我的),也可以互相同步(某些車道在交通燈亮?xí)r禁止繼續(xù)前行或轉(zhuǎn)彎,必須等待其它車道的車輛通行完畢)。
          4. 這些線程(車道)之間依靠代碼邏輯(交通燈)來控制運(yùn)行,一旦代碼邏輯控制有誤(死鎖,多個(gè)線程同時(shí)競(jìng)爭(zhēng)唯一資源),那么線程將陷入混亂,無序之中。
          5. 這些線程(車道)之間誰先運(yùn)行是未知的,只有在線程剛好被分配到CPU時(shí)間片(交通燈變化)的那一刻才能知道。

          JVM與多線程

          Java編寫的程序都運(yùn)行在Java虛擬機(jī)(JVM)中,在JVM的內(nèi)部,程序的多任務(wù)是通過線程來實(shí)現(xiàn)的。

          每用java命令啟動(dòng)一個(gè)java應(yīng)用程序,就會(huì)啟動(dòng)一個(gè)JVM進(jìn)程。在同一個(gè)JVM進(jìn)程中,有且只有一個(gè)進(jìn)程,就是它自己。在這個(gè)JVM環(huán)境中,所有程序代碼的運(yùn)行都是以線程來運(yùn)行的。JVM找到程序的入口點(diǎn)main(),然后運(yùn)行main()方法,這樣就產(chǎn)生了一個(gè)線程,這個(gè)線程稱之為主線程。當(dāng)main方法結(jié)束后,主線程運(yùn)行完成。JVM進(jìn)程也隨即退出。

          操作系統(tǒng)將進(jìn)程線程進(jìn)行管理,輪流(沒有固定的順序)分配每個(gè)進(jìn)程很短的一段時(shí)間(不一定是均分),然后在每個(gè)進(jìn)程內(nèi)部,程序代碼自己處理該進(jìn)程內(nèi)部線程的時(shí)間分配,多個(gè)線程之間相互的切換去執(zhí)行,這個(gè)切換時(shí)間也是非常短的。

          Java語言對(duì)多線程的支持

          Java語言對(duì)多線程的支持通過類Thread和接口Runnable來實(shí)現(xiàn)。這里就不多說了。這里重點(diǎn)強(qiáng)調(diào)兩個(gè)地方:

          // 主線程其它代碼段
          ThreadClass subThread = new ThreadClass();
          subThread.start();
          // 主線程其它代碼段
          subThread.sleep(1000);

          有人認(rèn)為以下的代碼在調(diào)用start()方法后,肯定是先啟動(dòng)子線程,然后主線程繼續(xù)執(zhí)行。在調(diào)用sleep()方法后CPU什么都不做,就在那里等待休眠的時(shí)間結(jié)束。實(shí)際上這種理解是錯(cuò)誤的。因?yàn)椋?/p>

          1. start()方法的調(diào)用后并不是立即執(zhí)行多線程代碼,而是使得該線程變?yōu)榭蛇\(yùn)行態(tài)(Runnable),什么時(shí)候運(yùn)行是由操作系統(tǒng)決定的。
          2. Thread.sleep()方法調(diào)用目的是不讓當(dāng)前線程獨(dú)自霸占該進(jìn)程所獲取的CPU資源,以留出一定時(shí)間給其他線程執(zhí)行的機(jī)會(huì)(也就是靠內(nèi)部自己協(xié)調(diào))。

          線程的狀態(tài)切換

          前面我們提到,由于線程何時(shí)執(zhí)行是未知的,只有在CPU為線程分配到時(shí)間片時(shí),線程才能真正執(zhí)行。在線程執(zhí)行的過程中,由可能會(huì)因?yàn)楦鞣N各樣的原因而暫停(就像前面所舉的例子一樣:汽車只有在交通燈變綠的時(shí)候才能夠通行,而且在行駛的過程中可能會(huì)出現(xiàn)塞車,等待其它車輛通行或轉(zhuǎn)彎的狀況)。

          這樣線程就有了“狀態(tài)”的概念,下面這副圖很好的反映了線程在不同情況下的狀態(tài)變化。

          線程在不同情況下的狀態(tài)變化

          • 新建狀態(tài)(New):新創(chuàng)建了一個(gè)線程對(duì)象。
          • 就緒狀態(tài)(Runnable):線程對(duì)象創(chuàng)建后,其他線程調(diào)用了該對(duì)象的start()方法。該狀態(tài)的線程位于可運(yùn)行線程池中,變得可運(yùn)行,等待獲取CPU的使用權(quán)。
          • 運(yùn)行狀態(tài)(Running):就緒狀態(tài)的線程獲取了CPU,執(zhí)行程序代碼。
          • 阻塞狀態(tài)(Blocked):阻塞狀態(tài)是線程因?yàn)槟撤N原因放棄CPU使用權(quán),暫時(shí)停止運(yùn)行。直到線程進(jìn)入就緒狀態(tài),才有機(jī)會(huì)轉(zhuǎn)到運(yùn)行狀態(tài)。阻塞的情況分三種:
            1. 等待阻塞:運(yùn)行的線程執(zhí)行wait()方法,JVM會(huì)把該線程放入等待池中。
            2. 同步阻塞:運(yùn)行的線程在獲取對(duì)象的同步鎖時(shí),若該同步鎖被別的線程占用,則JVM把該線程放入鎖。
            3. 其他阻塞:運(yùn)行的線程執(zhí)行sleep()或join()方法,或者發(fā)出了I/O請(qǐng)求時(shí),JVM會(huì)把該線程置為阻塞狀態(tài)。當(dāng)sleep()狀態(tài)超時(shí)、join()等待線程終止或者超時(shí)、或者I/O處理完畢時(shí),線程重新轉(zhuǎn)入就緒狀態(tài)。
          • 死亡狀態(tài)(Dead):線程執(zhí)行完了或者因異常退出了run()方法,該線程結(jié)束生命周期。

          Java中線程的調(diào)度API

          Java中關(guān)于線程調(diào)度的API最主要的有下面幾個(gè):

          1. 線程睡眠:Thread.sleep(long millis)方法
          2. 線程等待:Object類中的wait()方法
          3. 線程讓步:Thread.yield() 方法
          4. 線程加入:join()方法
          5. 線程喚醒:Object類中的notify()方法

          關(guān)于這幾個(gè)方法的詳細(xì)應(yīng)用,可以參考SUN的API。這里我重點(diǎn)總結(jié)一下這幾個(gè)方法的區(qū)別和使用。

          sleep方法與wait方法的區(qū)別:

          1. sleep方法是靜態(tài)方法,wait方法是非靜態(tài)方法。
          2. sleep方法在時(shí)間到后會(huì)自己“醒來”,但wait不能,必須由其它線程通過notify(All)方法讓它“醒來”。
          3. sleep方法通常用在不需要等待資源情況下的阻塞,像等待線程、數(shù)據(jù)庫連接的情況一般用wait。

          sleep/wait與yeld方法的區(qū)別:調(diào)用sleep或wait方法后,線程即進(jìn)入block狀態(tài),而調(diào)用yeld方法后,線程進(jìn)入runnable狀態(tài)。

          wait與join方法的區(qū)別:

          1. wait方法體現(xiàn)了線程之間的互斥關(guān)系,而join方法體現(xiàn)了線程之間的同步關(guān)系。
          2. wait方法必須由其它線程來解鎖,而join方法不需要,只要被等待線程執(zhí)行完畢,當(dāng)前線程自動(dòng)變?yōu)榫途w。
          3. join方法的一個(gè)用途就是讓子線程在完成業(yè)務(wù)邏輯執(zhí)行之前,主線程一直等待直到所有子線程執(zhí)行完畢。

          通過上面的介紹相信同學(xué)們對(duì)java里面的多線程已經(jīng)有了基本的了解和認(rèn)識(shí)。其實(shí)多線程編程并沒有大家想象中的那么難,只要在實(shí)際的學(xué)習(xí),工作當(dāng)中不斷的加以練習(xí)和使用,相信大家很快就能掌握其中的奧妙,從而編寫出賞心悅目的java程序。


          posted @ 2015-04-11 17:31 管先飛 閱讀(269) | 評(píng)論 (0)編輯 收藏

          1、多表級(jí)聯(lián)刪除:
          ---DELETE---
          DELETE from a_msg_push,a_announcement
          using a_msg_push,a_announcement
          where  a_msg_push.announcement_id=a_announcement.id and a_announcement.Create_time<'2014-11-19 23:59:59';

          2、子查詢刪除:
          -----------delete--------
          DELETE From  t_repeat  where t_repeat.id in(
          SELECT tb.id from (
          SELECT *  from t_repeat   t 
          where 
          1=1
          and 
          (t.cid,t.uid ) in (select t1.cid,t1.uid from t_repeat t1 group by t1.cid,t1.uid having count(*) > 1) 
          and 
          t.id  not in (select min(t2.id) from t_repeat t2 group by t2.cid,t2.uid having count(*)>1) 
          ) as tb )

          3、子表刪除:
          -----------delete--------
          DELETE From  t_repeat  where t_repeat.id  not in
             SELECT tb.id from(
          select  a.id from t_repeat a where a.id =(
          select   max(b.id) from t_repeat b where a.cid=b.cid and a.uid=b.uid
             )as tb
          )
          posted @ 2015-03-01 22:52 管先飛 閱讀(2560) | 評(píng)論 (0)編輯 收藏

          感謝廖雪峰為大家提供這么好的免費(fèi)教程,主要目錄如下:
          Git教程

          posted @ 2014-10-20 10:59 管先飛 閱讀(244) | 評(píng)論 (0)編輯 收藏

          gooole瀏覽器內(nèi)核已經(jīng)有webkit內(nèi)核移步到Bilnk開發(fā)屬于Chromium Projects 的版本,下面為完整教程。

          目錄

          1. Blink's Mission:
          2. Participating
            1. 2.1 Discussions
            2. 2.2 Watching for new features
            3. 2.3 Committing and reviewing code
            4. 2.4 Developing Blink
            5. 2.5 How do I port Blink to my platform?
          3. Web Platform Changes: Guidelines
            1. 3.1 Scope
            2. 3.2 Policy for shipping and removing web platform API features
            3. 3.3 Trivial Changes
            4. 3.4 Vendor Prefixes
          4. Web Platform Changes: Process
            1. 4.1 Launch Process: New Features
            2. 4.2 Launch Process: Deprecation
            3. 4.3 API Owners
            4. 4.4 API Review
            5. 4.5 Feature Dashboard
            6. 4.6 Guiding Principles for Process
          5. Testing
          6. Architectural Changes
          7. Developer FAQ
          8. Subpage Listing
            友情連接:
            https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html
          posted @ 2014-10-19 21:09 管先飛 閱讀(344) | 評(píng)論 (0)編輯 收藏

          如下兩條常用sql,統(tǒng)計(jì)分類數(shù)據(jù),你能說出區(qū)別嗎?
          一、常用sql一:
          select 
          r.cid,
          r.depart_id,
          r.employ_id,
          r.create_by,
          count(DISTINCT r.form_type) as dailyReportNum
          FROM 
          report r
          where 
          1=1 
          GROUP BY 
          r.employ_id

          二、常用sql二:
          select 
          r.cid,
          r.depart_id,
          r.employ_id,
          r.create_by,
          sum(case WHEN df.form_type=1 then 1 else 0 end ) as dailyReportNum
          FROM 
          report r
          where 
          1=1 
          GROUP BY 
          r.employ_id


          posted @ 2014-09-18 17:05 管先飛 閱讀(3598) | 評(píng)論 (4)編輯 收藏

          HSSF和XSSF的區(qū)別:
          http://poi.apache.org/spreadsheet/index.html
          POI官方詳情教程:
          http://poi.apache.org/spreadsheet/quick-guide.html

          Index of Features

          posted @ 2014-09-18 12:24 管先飛 閱讀(3817) | 評(píng)論 (2)編輯 收藏

          現(xiàn)階段JAVA操作Excel的JAR主要有apache 的POI及jxl.Jxl方便快捷,POI用于對(duì)復(fù)雜Excel的操作。

          Jxl官網(wǎng):http://www.andykhan.com/jexcelapi/index.html


          一、Jxl的API

          Jxl的API主要有三個(gè)包,jxl,jxl.format,jxl.write。如果單獨(dú)的分析API,可能對(duì)于更明確的了解此API沒有太多的幫助,我們還是從Excel文件的層次來剝離此API吧。

          一個(gè)excel文件由一個(gè)工作簿組成,一個(gè)工作簿又由n個(gè)工作表組成,每個(gè)工作表又由多個(gè)單元格組成。對(duì)應(yīng)于Jxl中的結(jié)構(gòu)為

          讀文件(包jxl)

          寫文件(包jxl.write)

          說明

          Workbook 

          WritableWorkbook

          工作簿

          Sheet

          WritableSheet

          工作表

          Cell/Image/Hyperlink

          WritableCell/WritableImage//WritableHyperlink

          單元格/圖像/超鏈接

                 單元格(此處指文本單元格,圖像及鏈接和單元格做為一個(gè)層次)分為好多種,所以在API的設(shè)計(jì)中將Cell作為一個(gè)接口而存在。 對(duì)應(yīng)的jxl中的結(jié)構(gòu)為:

          讀文件(包jxl)

          寫文件(包jxl.write)

          說明

          Cell

          WritableCell

          單元格

          BooleanCell

          Boolean

          布爾值單元格

          DateCell

          DateTime

          時(shí)間單元格

          ErrorCell

           

          形式錯(cuò)誤的單元格

          LabelCell

          Label

          文本單元格

          NumberCell

          Number

          數(shù)字單元格

          FormualCedll

          Formual

          公式單元格

           

          Blank

          空格單元格

          BooleanFormualCell

           

          布爾公式單元格

          DateFormualCell

           

          時(shí)間公式單元格

          ErrorFormualCell

           

          錯(cuò)誤公式單元格

          StringFormualCell

           

          文本公式單元格

          NumberFormualCell

           

          數(shù)字公式單元格

           

          而有的時(shí)候,我們可能將幾個(gè)單元格作為一個(gè)整體來處理,在API中對(duì)應(yīng)的則是:

              jxl.Range 

           

              雖然數(shù)據(jù)是電子表格的核心,但是同時(shí)其也需要一些輔助類,比如文件格式設(shè)置,工作表設(shè)置與顯示效果,單元格設(shè)置與顯示效果等。按照其層次,則依次有以下接口或類。

          讀文件(包jxl)

          寫文件(包jxl.write)

          說明

          WorkbookSettings

          WorkbookSettings(包jxl)

          設(shè)置workbook屬性的bean

          SheetSettings

          SheetSettings(包jxl)

          設(shè)置具體sheet的屬性的bean(比如表頭表底等)

          HeaderFooter

          HeaderFooter(包jxl)

          表示表頭表底類

          HeaderFooter.Contents

          HeaderFooter.Contents(包jxl)

          具體表頭表底設(shè)置

          CellFeatures

          WritableCellFeautres

          表格內(nèi)容相關(guān)設(shè)置(驗(yàn)證)

          CellReferenceHelper

           

          得到引用單元格相關(guān)屬性

          CellType

           

          表格相關(guān)類型

          CellView

          CellView(包jxl)

          表格視圖相關(guān)設(shè)置

          CellFormat

          WritableCellFormat

          表格顯示樣式設(shè)置

           

          BoldStyle

          邊框枚舉

           

          DateFormat

          時(shí)間格式

           

          DateFormats

          時(shí)間格式枚舉

           

          NumbreFormat

          數(shù)據(jù)格式

           

          NumbreFormats

          數(shù)字模式枚舉

           

          WritableFont

          字體設(shè)置

           

          WriteableFont.Fontname

          靜態(tài)字體內(nèi)部類

           

          最后,關(guān)于Jxl.format包,此包主要是一些與具體樣式有關(guān)的接口和枚舉,不進(jìn)行具體描述。
          文章摘自:http://blog.csdn.net/surgent/article/details/5836580

          posted @ 2014-09-18 09:21 管先飛 閱讀(2009) | 評(píng)論 (0)編輯 收藏

           網(wǎng)絡(luò)盒子目前市面上主流的有小米盒子、樂視盒子、Uhost、天貓盒子,各種盒子的功能都差不多,現(xiàn)以小米盒子為列簡單描述一下小米盒子。
          一、小米盒子的最新功能:
          1、觀看各種大片電影、電視劇。
          2、各種手游、教育培訓(xùn)。
          二、小米盒子的缺陷:
          1、用戶直觀搜索相關(guān)的視頻太困難,搜索功能太局限。
          2、網(wǎng)絡(luò)電視不支持,不過現(xiàn)在可以安裝其他視頻軟件來觀看網(wǎng)絡(luò)電視。
          3、對(duì)手機(jī)端的安卓apk支持不好。
          三、小米盒子的潛力:
          1、小米盒子的操作系統(tǒng)采用andriod操作系統(tǒng),以后可以包含手機(jī)上有的一切功能。
          2、以后在游戲、教育、影院、購物比手機(jī)更有發(fā)展?jié)摿Α?br />四、小米盒子的使用技巧:
          1、小米盒子最新miniui已經(jīng)支持root,所以可以安裝一切安卓應(yīng)用(安裝方法類似手機(jī))。
          2、小米盒子系統(tǒng)更新保持網(wǎng)絡(luò)暢通。
          4、可以將手機(jī)片源用電視播放,也可用手機(jī)玩游戲。
          簡單寫幾個(gè)小文字睡覺,希望幫電視盒子打打廣告,以后希望盒子發(fā)展得更好,豐富用戶余業(yè)觀看在客廳的娛樂體驗(yàn)。
          posted @ 2014-06-15 01:34 管先飛 閱讀(2005) | 評(píng)論 (10)編輯 收藏

               摘要: package org.jeecgframework.core.util.excel;import java.awt.image.BufferedImage;import java.io.ByteArrayOutputStream;import java.io.File;import java.io.IOException;import java.lang.reflect.Field;import...  閱讀全文
          posted @ 2014-05-29 11:14 管先飛 閱讀(7877) | 評(píng)論 (0)編輯 收藏

          JSON轉(zhuǎn)換的四種各種情況:

          1. //把java 對(duì)象列表轉(zhuǎn)換為json對(duì)象數(shù)組,并轉(zhuǎn)為字符串

              JSONArray array = JSONArray.fromObject(userlist);
              String jsonstr = array.toString();

          2.//把java對(duì)象轉(zhuǎn)換成json對(duì)象,并轉(zhuǎn)化為字符串

            JSONObject object = JSONObject.fromObject(invite);
             String str=object.toString());

          3.//把JSON字符串轉(zhuǎn)換為JAVA 對(duì)象數(shù)組

            String personstr = getRequest().getParameter("persons");
            JSONArray json = JSONArray.fromObject(personstr);
            List<InvoidPerson> persons = (List<InvoidPerson>)JSONArray.toCollection(json, nvoidPerson.class);
          4.//把JSON字符串轉(zhuǎn)換為JAVA 對(duì)象

            JSONObject jsonobject = JSONObject.fromObject(str);
            PassportLendsEntity passportlends = null;
            try {
             //獲取一個(gè)json數(shù)組
             JSONArray array = jsonobject.getJSONArray("passports");
             //將json數(shù)組 轉(zhuǎn)換成 List<PassPortForLendsEntity>泛型
             List<PassPortForLendsEntity> list = new ArrayList<PassPortForLendsEntity>();
             for (int i = 0; i < array.size(); i++) {   
                      JSONObject object = (JSONObject)array.get(i);  
                      PassPortForLendsEntity passport = (PassPortForLendsEntity)JSONObject.toBean(object,
                        PassPortForLendsEntity.class);
                      if(passport != null){
                       list.add(passport);
                      }  
               }
             //轉(zhuǎn)換PassportLendsEntity 實(shí)體類
            passportlends = (PassportLendsEntity)JSONObject.toBean(jsonobject, PassportLendsEntity.class);

            str = "{\"lendperson\":\"李四\",\"lendcompany\":\"有限公司\",\"checkperson\":\"李四\",

            \"lenddate\":\"2010-07-19T00:00:00\",\"lendcounts\":4,\"
            passports\":[{\"passportid\":\"d\",\"name\":\"李豫川\",\"passporttype\":\"K\"},
            {\"passportid\":\"K9051\",\"name\":\"李平\",\"passporttype\":\"K\"},
            {\"passportid\":\"K90517\",\"name\":\"袁寒梅\",\"passporttype\":\"K\"},
            {\"passportid\":\"K905199\",\"name\":\"賀明\",\"passporttype\":\"K\"}]}";
          相關(guān)的jar包:

          posted @ 2014-04-16 01:11 管先飛 閱讀(2757) | 評(píng)論 (0)編輯 收藏


          CriteriaQuery cq = new CriteriaQuery(MsgRecordEntity.class, datagrid);
          cq.add(Restrictions.eq("cid", cid));
          Criterion c1=cq.and(Restrictions.eq("sendEid", sendEid),Restrictions.eq("pointEid", pointEid)) ;
          Criterion c2=cq.and(Restrictions.eq("sendEid",pointEid ),Restrictions.eq("pointEid", sendEid)) ;
          cq.or(c1, c2);
          cq.add(Restrictions.eq("flag",AilkConstant.FLAG_NOT_REMOVED));
          cq.addOrder("sendDate", SortDirection.desc);
          cq.add();
          posted @ 2014-04-14 10:42 管先飛 閱讀(2201) | 評(píng)論 (0)編輯 收藏

          1、修改內(nèi)聯(lián)表
          update a_locationservice al,t_kxt_executor_info t 
          set al.objid= t.id
          where al.location_id=t.end_location_id
          and  al.objtype='8' and al.objid is null
          2、修改級(jí)聯(lián)表:
          update t_kxt_executor_info_detail tid
          LEFT JOIN 
             t_kxt_common_reports crep  
          on 
           crep.id=tid.obj_id
          set tid.flag='2'
          where  (tid.obj_type='terminalPhotograph' or tid.obj_type='requestInfo' or tid.obj_type='terminalInfo')  and  crep.id is null
          posted @ 2014-02-26 11:09 管先飛 閱讀(242) | 評(píng)論 (0)編輯 收藏

               摘要: 關(guān)于Tomcat: 安裝Tomcat:sudo apt-get install tomcat7 配置tomcat:http://wiki.ubuntu.org.cn/Tomcat 啟動(dòng)tomcat:my-instance/bin/startup.sh關(guān)閉tomcat:my-instance/bin/shutdown.sh關(guān)于系統(tǒng)進(jìn)程:ps ax   顯示當(dāng)前...  閱讀全文
          posted @ 2014-02-25 10:17 管先飛 閱讀(498) | 評(píng)論 (0)編輯 收藏

          1.UNIX很簡單。但需要有一定天賦的人才能理解這種簡單。——Dennis Ritchie
          2.軟件在能夠復(fù)用前必須先能用。——Ralph Johnson
          3.優(yōu)秀的判斷力來自經(jīng)驗(yàn),但經(jīng)驗(yàn)來自于錯(cuò)誤的判斷。——Fred Brooks
          4.‘理論’是你知道是這樣,但它卻不好用。‘實(shí)踐’是它很好用,但你不知道是為什么。程序員將理論和實(shí)踐結(jié)合到一起:既不好用,也不知道是為什么。——佚名
          5.當(dāng)你想在你的代碼中找到一個(gè)錯(cuò)誤時(shí),這很難;當(dāng)你認(rèn)為你的代碼是不會(huì)有錯(cuò)誤時(shí),這就更難了。——Steve McConnell 《代碼大全》
          6.如果建筑工人蓋房子的方式跟程序員寫程序一樣,那第一只飛來的啄木鳥就將毀掉人類文明。——Gerald Weinberg
          7.項(xiàng)目開發(fā)的六個(gè)階段:1. 充滿熱情 2. 醒悟 3. 痛苦 4. 找出罪魁禍?zhǔn)?5. 懲罰無辜 6. 褒獎(jiǎng)閑人——佚名
          8.優(yōu)秀的代碼是它自己最好的文檔。當(dāng)你考慮要添加一個(gè)注釋時(shí),問問自己,“如何能改進(jìn)這段代碼,以讓它不需要注釋?”——Steve McConnell 《代碼大全》
          9.我們這個(gè)世界的一個(gè)問題是,蠢人信誓旦旦,智人滿腹狐疑。——Bertrand Russell
          10.無論在排練中演示是如何的順利(高效),當(dāng)面對(duì)真正的現(xiàn)場(chǎng)觀眾時(shí),出現(xiàn)錯(cuò)誤的可能性跟在場(chǎng)觀看的人數(shù)成正比。——佚名
          11.羅馬帝國崩潰的一個(gè)主要原因是,沒有0,他們沒有有效的方法表示他們的C程序成功的終止。——Robert Firth
          12.C程序員永遠(yuǎn)不會(huì)滅亡。他們只是cast成了void。——佚名
          13.如果debugging是一種消滅bug的過程,那編程就一定是把bug放進(jìn)去的過程。——Edsger Dijkstra
          14.你要么要軟件質(zhì)量,要么要指針?biāo)惴ǎ粌烧卟豢杉娴谩?#8212;—(Bertrand Meyer)
          15.有兩種方法能寫出沒有錯(cuò)誤的程序;但只有第三種好用。——Alan J. Perlis
          16.用代碼行數(shù)來測(cè)評(píng)軟件開發(fā)進(jìn)度,就相對(duì)于用重量來計(jì)算飛機(jī)建造進(jìn)度。——比爾·蓋茨
          17.最初的90%的代碼用去了最初90%的開發(fā)時(shí)間。余下的10%的代碼用掉另外90%的開發(fā)時(shí)間。——Tom Cargill
          18.程序員和上帝打賭要開發(fā)出更大更好——傻瓜都會(huì)用的軟件。而上帝卻總能創(chuàng)造出更大更傻的傻瓜。所以,上帝總能贏。——Anon

          轉(zhuǎn)自:http://www.zhishihai.net/diannaowangluo/biancheng/bianchengsixiang/145.html
          posted @ 2013-11-10 18:54 管先飛 閱讀(272) | 評(píng)論 (0)編輯 收藏

          package com.exl.test;
          import java.awt.Color;
          import java.io.File;
          import jxl.CellView;
          import jxl.Workbook;
          import jxl.format.Alignment;
          import jxl.format.Colour;
          import jxl.format.UnderlineStyle;
          import jxl.write.Label;
          import jxl.write.WritableCellFormat;
          import jxl.write.WritableFont;
          import jxl.write.WritableSheet;
          import jxl.write.WritableWorkbook;
          import com.exl.utils.ColourUtil;
          public class Test {
             public static void main(String[] args) throws Exception {
            String title="報(bào)表測(cè)試";
            String[] navTitle= {"第一行","第二行","第三行","第四行","第五行","第六行","第七行","第八行"};  
            String[][] content={
            {"1","2","第naionfdapfn三行","第四niaodnfoanfdas行","第noandfoasnjdf五行","第六sdfadsafas行","第afdadfasdfs七a行","第adfasfdasf八行"},
            {"2","2","第三行","第四行","第五行","第六行","第七行","sssssssssss第八sss行"},
            {"3","2","第三行","第四行","第五行","第六行","第七行","第八行sssssssssssss"},
            {"4","2","第三行","第四行","第sssssssssssssss五行","第ssssssssssssssssssss六行","第七行","第八行sssssssss"},
            {"5","2","第三行","第ddddddddddddddddddddddddddddddddddddddddddddddddddddddddd四行","第五行","第六行","第七行","第八行"},
            {"6","2","第三行","第四行","第五行","第六行","第七行","第八行"},
            {"7","2","第三行","第四ddddddddddddddddddddddddddddddd行","第五行","第六行","第七行","第八行"},
            {"8","2","第三行","第四行","第五行","第六行","第七行","第八行"},
            {"9","2","第三行","第ddddddddddddddddddddddddddddddd四行","第五行","第六行","第七行","第八行"},
            {"10","2","第三行","第四行","第五行","第六行","第七行","第八行"},
            {"11","2","第三行","第四行","第五行","第六dddddddddddddd行","第七行","第八行"},
            {"12","2","第三行","第四行","第五行","第六行","第七行","第八行"},
            {"13","2","第三行","第四行","第五行","dddddddddddddddddddddd第六行","第七行","第八行"},
            {"14","2","第三行","第四行","第五行","第dddddddddddddddddddddd六行","第七行","第八行"},
            };  
            String filePath="D:\\DesignSource\\tempT";
            String fileName="NewProject.xls";
            File dir=new  File(filePath);
            if(!dir.isDirectory()){
            dir.mkdirs();
            }
            
                 File file = new File(filePath+"\\"+fileName);
                 WritableWorkbook workbook = Workbook.createWorkbook(file);  
                 WritableSheet sheet = workbook.createSheet("報(bào)表統(tǒng)計(jì)", 0);  //單元格
                 /**
                  * title
                  */
                 Label lab = null;  
                 WritableFont   wf2   =   new   WritableFont(WritableFont.ARIAL,14,WritableFont.BOLD,false,UnderlineStyle.NO_UNDERLINE,jxl.format.Colour.BLACK); // 定義格式 字體 下劃線 斜體 粗體 顏色
                 WritableCellFormat wcfTitle = new WritableCellFormat(wf2);
                 wcfTitle.setBackground(jxl.format.Colour.IVORY);  //象牙白
                 wcfTitle.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN,jxl.format.Colour.BLACK); //BorderLineStyle邊框
                 //       wcfTitle.setVerticalAlignment(VerticalAlignment.CENTRE); //設(shè)置垂直對(duì)齊
                 wcfTitle.setAlignment(Alignment.CENTRE); //設(shè)置垂直對(duì)齊
                 
                 CellView navCellView = new CellView();  
                 navCellView.setAutosize(true); //設(shè)置自動(dòng)大小
                 navCellView.setSize(18);
                 
                 lab = new Label(0,0,title,wcfTitle); //Label(col,row,str);   
                 sheet.mergeCells(0,0,navTitle.length-1,0);
                 sheet.setColumnView(0, navCellView); //設(shè)置col顯示樣式
                 sheet.setRowView(0, 1600, false); //設(shè)置行高
                 sheet.addCell(lab);  
                 /**
                  * status
                  */
                 
                 
                 /**
                  * nav
                  */
                 jxl.write.WritableFont wfcNav =new jxl.write.WritableFont(WritableFont.ARIAL,12, WritableFont.BOLD,false,UnderlineStyle.NO_UNDERLINE,jxl.format.Colour.BLACK);
                  WritableCellFormat wcfN=new WritableCellFormat(wfcNav);
                  
                  Color color = Color.decode("#0099cc"); // 自定義的顏色
          workbook.setColourRGB(Colour.ORANGE, color.getRed(),color.getGreen(), color.getBlue());
                 wcfN.setBackground(Colour.ORANGE);
                 wcfN.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN,jxl.format.Colour.BLACK); //BorderLineStyle邊框
                 wcfN.setAlignment(Alignment.CENTRE); //設(shè)置水平對(duì)齊
                 wcfN.setWrap(false); //設(shè)置自動(dòng)換行
                 for(int i=0;i<navTitle.length;i++){
                lab = new Label(i,1,navTitle[i],wcfN); //Label(col,row,str);   
                sheet.addCell(lab);  
                sheet.setColumnView(i, new String(navTitle[i]).length());  
                 }
                 
                 /**
                  * 內(nèi)容
                  */
                 jxl.write.WritableFont wfcontent =new jxl.write.WritableFont(WritableFont.ARIAL,12, WritableFont.NO_BOLD,false,UnderlineStyle.NO_UNDERLINE,jxl.format.Colour.GREEN);
                 WritableCellFormat wcfcontent = new WritableCellFormat(wfcontent);
                 wcfcontent.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN,jxl.format.Colour.BLACK); //BorderLineStyle邊框
                 wcfcontent.setAlignment(Alignment.CENTRE);
                 CellView cellView = new CellView();  
                 cellView.setAutosize(true); //設(shè)置自動(dòng)大小
                 for(int i=0;i<content.length;i++){  
                     for(int j=0;j<content[i].length;j++){  
                    sheet.setColumnView(i, cellView);//根據(jù)內(nèi)容自動(dòng)設(shè)置列寬  
                    lab = new Label(j,i+2,content[i][j],wcfcontent); //Label(col,row,str);  
                         sheet.addCell(lab);  
          //               sheet.setColumnView(j, new String(content[i][j]).length());  
                     }  
                 }  
                 
                 workbook.write();  
                 workbook.close();  
          }
          }
          posted @ 2013-10-17 01:18 管先飛 閱讀(40055) | 評(píng)論 (1)編輯 收藏

          1、請(qǐng)求下載地址:
          try {
          //執(zhí)行檢索
          cmsSupSubmitSiteStatBeanList = cmsSupSubmitSiteInfoMngService.govStat(condition);
          //根據(jù)條件查找
          cmsSupSubmitSiteInfoMngBeanList = cmsSupSubmitSiteInfoMngService.findByConditionStat(condition);
          //臨時(shí)文件位置
          String path=this.getServletConfig().getServletContext().getRealPath("\\upload\\temp");
          File ftemp=new File(path);
          if (!ftemp.exists()) {
          ftemp.mkdirs();//不存在則創(chuàng)建
          }
          //生成臨時(shí)文件名
          String saveFilename = DateUtil.formatNowDateTime("yyyyMMddHHmmssSSS")+getNewName()+ ".csv";
          WritableWorkbook book = Workbook.createWorkbook(new File(path + "\\"+saveFilename));// 創(chuàng)建excel文件
          // 生成名為“第一頁”的工作表,參數(shù)0表示這是第一頁
          WritableSheet sheet = book.createSheet("網(wǎng)站信息統(tǒng)計(jì)表", 0);
          // 在Label對(duì)象的構(gòu)造子中指名單元格位置是第一列第一行(0,0)
          //標(biāo)題
          String[] title1 = {"單位名稱"
          ,"1月"
          ,"2月"
          ,"3月"
          ,"4月"
          ,"5月"
          ,"6月"
          ,"7月"
          ,"8月"
          ,"9月"
          ,"10月"
          ,"11月"
          ,"12月"
          ,"總報(bào)送量"
          ,"報(bào)送率"
          ,"分?jǐn)?shù)"
          ,"加減分"
          ,"總分?jǐn)?shù)"
          };
          //表頭
          for(int i=0;i<title1.length;i++){
          //第n列第一行標(biāo)識(shí)表頭
          Label label = new Label(i, 0, title1[i]);
          sheet.addCell(label); //將定義好的單元格添加到工作表中 
          }
          //內(nèi)容
          for (int i = 0; i < cmsSupSubmitSiteStatBeanList.size(); i++) {
          CmsSupSubmitSiteStatBean bean = cmsSupSubmitSiteStatBeanList.get(i);
          //內(nèi)容
          String[] rs1 = {  bean.getDeptName()
          ,String.valueOf(bean.getUsed01()) + "/" + String.valueOf(bean.getSup01())
          ,String.valueOf(bean.getUsed02()) + "/" + String.valueOf(bean.getSup02())
          ,String.valueOf(bean.getUsed03()) + "/" + String.valueOf(bean.getSup03())
          ,String.valueOf(bean.getUsed04()) + "/" + String.valueOf(bean.getSup04())
          ,String.valueOf(bean.getUsed05()) + "/" + String.valueOf(bean.getSup05())
          ,String.valueOf(bean.getUsed06()) + "/" + String.valueOf(bean.getSup06())
          ,String.valueOf(bean.getUsed07()) + "/" + String.valueOf(bean.getSup07())
          ,String.valueOf(bean.getUsed08()) + "/" + String.valueOf(bean.getSup08())
          ,String.valueOf(bean.getUsed09()) + "/" + String.valueOf(bean.getSup09())
          ,String.valueOf(bean.getUsed10()) + "/" + String.valueOf(bean.getSup10())
          ,String.valueOf(bean.getUsed11()) + "/" + String.valueOf(bean.getSup11())
          ,String.valueOf(bean.getUsed12()) + "/" + String.valueOf(bean.getSup12())
          ,String.valueOf(bean.getTolUsed()) + "/" + String.valueOf(bean.getTolSup())
          ,String.valueOf(bean.getUsedRate()) + "%"
          ,String.valueOf(bean.getPoint())
          ,String.valueOf(bean.getPmPoint())
          ,String.valueOf(bean.getTolPoint())
          };
          //內(nèi)容從第二行開始打印
          for (int j = 0; j < rs1.length; j++) {
          Label label = new Label(j, i+1, rs1[j]);
           sheet.addCell(label);
          }
          }
          // 打印詳細(xì)========================================================================================
          String[] stDtl = {  "單位名稱"
          ,"標(biāo)題"
          ,"加減分"
          ,"報(bào)送時(shí)間"
          };
          WritableSheet sheet2 = book.createSheet("網(wǎng)站信息采用標(biāo)題", 0);
          // 在Label對(duì)象的構(gòu)造子中指名單元格位置是第一列第一行(0,0)
          //標(biāo)題
          //表頭
          for(int i=0;i<stDtl.length;i++){
          //第n列第一行標(biāo)識(shí)表頭
          Label labe2 = new Label(i, 0, stDtl[i]);
          sheet2.addCell(labe2);
          }
          //內(nèi)容
          String titleVar="";
          int flagNum=0;
          for( int i = 0; i < cmsSupSubmitSiteInfoMngBeanList.size(); i ++ ){
          CmsSupSubmitSiteInfoMngBean bean = cmsSupSubmitSiteInfoMngBeanList.get(i);
          String[] rs2 = {bean.getSpDeptName()
          ,bean.getSupTitle()
          ,String.valueOf(bean.getMsgPmPoint())
          ,bean.getAddDate()
          };
          if(!titleVar.equals(rs2[0])){
          for (int x =0; x < rs2.length; x++) {
          Label labeVar2 = new Label(x, i+1, rs2[x]);
          sheet2.addCell(labeVar2);
          }
             }else{
              //內(nèi)容從第二行開始打印
                 //sheet.mergeCells(int col1,int row1,int col2,int row2);//左上角到右下角    
                  sheet.mergeCells(0,1, 0,flagNum);//左上角到右下角     ,列,行,列,行
          for (int j =1; j < rs2.length; j++) {
          Label labe2 = new Label(j, i+1, rs2[j]);
          sheet2.addCell(labe2);
          }
             }
          flagNum++;
          titleVar=rs2[0];
          }
          // // 將定義好的單元格添加到工作表中
          // /*
          // * 生成一個(gè)保存數(shù)字的單元格 必須使用Number的完整包路徑,否則有語法歧義 單元格位置是第二列,第一行,
          // 值為789.123
          // */
          // // jxl.write.Number number = new jxl.write.Number( 1 , 0 , 555.12541 );
          // // sheet.addCell(number);
          // 寫入數(shù)據(jù)并關(guān)閉文件
          book.write();
          book.close();
          // 將生成的文件下載
          AttUploadsServlet servlet=new AttUploadsServlet();
          servlet.downLoadFile(req, resp, "網(wǎng)站信息統(tǒng)計(jì).csv", path + "\\" + saveFilename);
          } catch (Exception e) {
          System.out.println(e);
          }

          2、下載附件:
          /**
          * 文檔下載
          * @param request 
          * @param response
          * @param fileName 文件名
          * @param attachment -文件路徑
          * @return
          */
          public boolean downLoadFile(HttpServletRequest request,HttpServletResponse response
          ,String fileName,String attachment) {
          try
          {
          String filepath =attachment;
          File file = new File(filepath);
          if(!file.exists())
          {
          return false;
          //throw new Exception(filepath+"文件未找到!");
          }
          BufferedInputStream br = new BufferedInputStream(new FileInputStream(file));
          byte[] buf = new byte[1024];
          int len = 0;
          response.reset();                                            //非常重要
          //純下載方式
          response.setContentType("application/x-msdownload"); 
          response.setHeader("Content-Disposition", "attachment; filename=" 
          + (new String(fileName.getBytes("gb2312"),"ISO-8859-1"))); 
          OutputStream out = response.getOutputStream();
          while((len = br.read(buf)) >0)
          out.write(buf,0,len);
          out.flush();
          br.close();
          return true;
          }
          catch(Exception ex)
          {
          log.info(ex.getMessage());
          return false;
          }
          }

          多學(xué)一點(diǎn):劃服務(wù)器下載附件
          <%@page import="java.io.FileInputStream"%>
          <%@page import="java.io.*"%>
          <%@page import="java.io.File"%>
          <%@page import="java.io.OutputStream"%>
          <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
          <%@page import="java.net.URL"%>
          <%@page import="java.net.URLConnection"%>
          <!-- 以上這行設(shè)定本網(wǎng)頁為Word格式的網(wǎng)頁 -->  
          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          <html xmlns="http://www.w3.org/1999/xhtml">
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
          </head>
          <%
             String refFilePath= request.getRealPath(new String(request.getParameter("fileSrc").getBytes("ISO-8859-1"),"UTF-8"));
             //String docName = new String(request.getParameter("fileName").getBytes("ISO-8859-1"),"UTF-8");
            request.setCharacterEncoding("UTF-8");
            String docName = request.getParameter("fileName");
            try{
                  /* 創(chuàng)建輸入流 */  
                   InputStream is = this.getClass().getClassLoader().getResourceAsStream("project.properties"); 
                  Properties p = new Properties();
                try {
               p.load(is);       //Properties 對(duì)象已生成,包括文件中的數(shù)據(jù)
                }catch(IOException e){
                 e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
                }
                
                String refFp=p.getProperty("xzql.refFilePath");
                  URL ul=new URL(refFp+new String(request.getParameter("fileSrc").getBytes("ISO-8859-1"),"UTF-8"));
                  URLConnection conn=ul.openConnection();
                  InputStream inStream = conn.getInputStream();
                  String disName = java.net.URLEncoder.encode(docName, "UTF-8");  
                  response.reset();  
                  response.setContentType("application/x-msdownload");  
                  response.addHeader("Content-Disposition",  
                          "attachment; filename=\"" + disName + "\"");  
                   
                  
                  byte[] buf = new byte[4096];  
                  /* 創(chuàng)建輸出流 */  
                  ServletOutputStream servletOS = response.getOutputStream();  
                  int readLength;
                  int alllength=0;
                  while (((readLength = inStream.read(buf)) != -1)) {  
                      servletOS.write(buf, 0, readLength); 
                      alllength+= readLength;
                  }
                  response.setContentLength(alllength); 
                  inStream.close();  
                  servletOS.flush();  
                  servletOS.close();  
             }catch(Exception e){
            out.print("文件不存在! ");
            e.printStackTrace();
            %> 
            </html>

          2).struts2下載Excel:
          http://blog.csdn.net/weinianjie1/article/details/5941042





          posted @ 2013-10-14 01:46 管先飛 閱讀(611) | 評(píng)論 (0)編輯 收藏

          myeclipse中的字體看上去比較舒服,但是忽然使用eclipse找不到該字體。具體介紹及解決辦法如下:
          myeclipse用Courier New這個(gè)字體,但是這個(gè)字體在Eclipse中默認(rèn)是選不出來的。到Eclipse preference--->colors and fonts中 找到選擇字體的地方(選擇字體的下拉菜單中是找不到Courier New的),在左下方有一行藍(lán)色的字“顯示更多字體”,點(diǎn)擊后會(huì)出現(xiàn)一個(gè)新的界面,這里會(huì)顯示你機(jī)器上所有的字體。找到Courier New后點(diǎn)擊右鍵選擇[顯示],然后關(guān)閉這個(gè)界面?;氐礁淖煮w的界面后你會(huì)發(fā)現(xiàn)下拉菜單中已經(jīng)可以選擇Courier New搜索這個(gè)字體了。然后將該字體默認(rèn)即可!
          posted @ 2013-09-15 23:51 管先飛 閱讀(3231) | 評(píng)論 (0)編輯 收藏

          mysql代碼:
          select sp.singer_name as singerName,sp.fans_value as fansValue

          From singer_publish sp 
          where 1=1   
          order by  (case  when  (sp.fans_value is null or sp.fans_value='' or sp.fans_value<1) then 1 else 0 end ),sp.fans_value; 
          posted @ 2013-09-10 15:11 管先飛 閱讀(889) | 評(píng)論 (0)編輯 收藏

           /*
          * 智能機(jī)瀏覽器版本信息:
          */
            var browser={
              versions:function(){
                     var u = navigator.userAgent, app = navigator.appVersion;
                     return {//移動(dòng)終端瀏覽器版本信息
                          trident: u.indexOf('Trident') > -1, //IE內(nèi)核
                          presto: u.indexOf('Presto') > -1, //opera內(nèi)核
                          webKit: u.indexOf('AppleWebKit') > -1, //蘋果、谷歌內(nèi)核
                          gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐內(nèi)核
                          mobile: !!u.match(/AppleWebKit.*Mobile.*/)||!!u.match(/AppleWebKit/), //是否為移動(dòng)終端
                          ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios終端
                          android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android終端或者uc瀏覽器
                          iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, //是否為iPhone或者QQHD瀏覽器
                          iPad: u.indexOf('iPad') > -1, //是否iPad
                          webApp: u.indexOf('Safari') == -1 //是否web應(yīng)該程序,沒有頭部與底部
                      };
                   }(),
                   language:(navigator.browserLanguage || navigator.language).toLowerCase()
          if(browser.versions.iPhone || browser.versions.iPad)
          {
          }
          else
          {
           
          }
          posted @ 2013-09-10 15:10 管先飛 閱讀(279) | 評(píng)論 (0)編輯 收藏

          人們常說程序員的生活枯燥為人刻板,其實(shí)這是你不懂程序員,代碼之外,這些高智商的人幽默有趣,論壇常常是他們展現(xiàn)才華的地方,BLOG是他們分享技術(shù)的地方,BBS等地方有問題他門總是熱心幫助解答,處理程序異常,修改程序錯(cuò)誤等。

            程序員也是很懂得品味人生的,因?yàn)楣ぷ饔绊懰T也許會(huì)對(duì)生活感慨,傷感自己沒足夠或是更多的時(shí)間去做工作之外的別的事。陪朋友,親戚,家人、甚至陪女朋友去買套漂亮的衣服的時(shí)間都沒有等。但是我個(gè)人意見認(rèn)為,程序員是最誠實(shí)、最實(shí)用主義及最愛恨分明的,平日工作雖然單調(diào)但不乏味。

            程序員是最誠實(shí)從何談起?

            程序員在學(xué)習(xí)和工作期間幾乎天天和機(jī)器打交道,壓根就沒有受欺負(fù)或是欺負(fù)別人的機(jī)會(huì),勤奮的程序員在調(diào)試無窮多的程序BUG時(shí),已經(jīng)深深地接受了“誠實(shí)”的教育,不誠實(shí)的人,他肯定不想做、也做不好程序員。

            為何說程序員是最實(shí)用主義?

            在10年前我第一次聽說電腦,后來初中文化課程中也開設(shè)了叫《計(jì)算機(jī)信息技術(shù)》這么一門課程,當(dāng)時(shí)老師不停的在講臺(tái)上給我們講計(jì)算機(jī)是如何的厲害,但他在我門心里一直只是個(gè)神話傳說,上一年的計(jì)算機(jī)課還沒曾見過真正的計(jì)算機(jī)的廬山真面目,只是從老師的口中聽說過他是如何的神。從我聽說計(jì)算機(jī)到后來我學(xué)習(xí)計(jì)算機(jī)甚至是現(xiàn)在我從事的計(jì)算機(jī)的工作,已經(jīng)過去了10個(gè)春夏秋冬了,但是目前最先進(jìn)的計(jì)算機(jī)也不具備智能,他其實(shí)是笨的他也需要人員去操作,當(dāng)我成為程序員的那刻我意識(shí)到計(jì)算機(jī)的神話是眾多程序員的汗水堆積起來的。

                 程序員的工作就是把復(fù)雜的問題轉(zhuǎn)化為計(jì)算機(jī)能處理的簡單的程序。如果一個(gè)問題復(fù)雜到連程序員自己都不能理解,他就無法編寫程序讓更笨的計(jì)算機(jī)來處理,所以程序信奉“簡單----實(shí)用”主義。

            程序員如何的愛恨分明?

            程序員大都喜歡技術(shù)挑戰(zhàn),不喜歡搞測(cè)試與維護(hù)。高水平的程序員喜歡和高水平的程序員一起工作,我也是這樣的一個(gè)人,我怕“與臭棋佬下棋,棋越下越臭”。

            也許是因?yàn)楣ぷ饔绊懀蓍e太少吧,程序員大都不喜歡拉幫結(jié)派、耍政治手腕。不信,你數(shù)數(shù)你認(rèn)識(shí)的程序員,有幾個(gè)人黨派人士?又有幾個(gè)是政府官員?說到這里我想到了窮人,因?yàn)槲乙彩歉F人之一。窮人為什么總是窮,很難變?yōu)楦辉5娜四兀恳驗(yàn)楦F人怕,怕付出沒回報(bào),怕投資得不到利益。怕高官怕大人物以至于不趕去和異類人群接觸,始終活動(dòng)在窮人堆里,又怎么會(huì)變得富裕呢?出非出現(xiàn)奇跡,麻雀巢里飛出個(gè)金鳳凰。呵呵,說遠(yuǎn)了。

            何解工作單調(diào)卻不乏味?

            程序設(shè)計(jì)的真正含義是什么?

            要塑造一個(gè)程序員又需要多少時(shí)間和經(jīng)歷呢?又有那些過程呢?學(xué)習(xí)過程的天空是黑暗的,記得以前在大學(xué)的時(shí)候,每天起床后的第一件事就是打開電腦,然后洗溯吃飯,接著就是看書寫代碼這些,餓了又去吃飯然后又面對(duì)電腦,當(dāng)困了的時(shí)候就倒下睡覺。醒了又爬起來,很少和朋友家人聯(lián)系,每天都過著這樣的單調(diào)的循環(huán)生活,但很遺憾的是我和電腦這么的親密接觸到現(xiàn)在還是不能達(dá)到人機(jī)合一的境界。

            我記得我曾經(jīng)說過,我最好的朋友是我的電腦,無論我是高興還是煩惱,無論我是興奮還是疲倦,一直陪伴著我的始終是他。但這句話是針對(duì)不同的時(shí)間到,如果參加工作了,或許工作中的任務(wù)、同事之間的友誼、個(gè)人生活中的感情等等都將會(huì)成為我們的最愛。總的來說是因事而異、因人而異。

            餓了就吃,困了就睡,只要時(shí)機(jī)恰當(dāng)就進(jìn)行程序設(shè)計(jì)。生活、學(xué)習(xí)及工作融為一體,盡管單調(diào)卻不乏味,還能獨(dú)享孤獨(dú)。

               原文連接:http://blog.sina.com.cn/s/blog_883c46a60101a8ez.html

          posted @ 2013-05-19 23:35 管先飛 閱讀(270) | 評(píng)論 (0)編輯 收藏

          1、程序猿最煩兩件事,第一件事是別人要他給自己的代碼寫文檔,第二件呢?是別人的程序沒有留下文檔。

          2、程序猿的讀書歷程:x 語言入門 —> x 語言應(yīng)用實(shí)踐 —> x 語言高階編程 —> x 語言的科學(xué)與藝術(shù) —> 編程之美 —> 編程之道 —> 編程之禪—> 頸椎病康復(fù)指南。

          3、還沒上大學(xué)的時(shí)候,高三暑假,跑到家那邊的圖書城想買傳說中的C++的書,然后看到一本C#,我一看,嘿,這個(gè)++還寫得挺藝術(shù)的,重疊起來了,于是把C#買了回來……

          4、問:程序猿最討厭康熙的哪個(gè)兒子。答:胤禩。因?yàn)樗前税⒏纾╞ug)

          5、有一天,程序猿們突然發(fā)現(xiàn)他們要漲的工資掉到井里啦!大家都很害怕,連忙一個(gè)吊著一個(gè),從樹上伸到井里去撈工資。正好他們摸到工資的時(shí)候,一個(gè)老程序員忽然興奮的大叫:別蠢了,要漲的工資還好好的掛在天上呢!

          6、諸葛亮是一個(gè)優(yōu)秀的程序猿,每一個(gè)錦囊都是應(yīng)對(duì)不同的case而編寫的!但是優(yōu)秀的程序猿也敵不過更優(yōu)秀的bug!六出祈山,七進(jìn)中原,鞠躬盡瘁,死而后已的諸葛亮只因?yàn)橛幸粋€(gè)錯(cuò)誤的case-馬謖,整個(gè)結(jié)構(gòu)就被break了!

          7、生活中程序猿的真實(shí)寫照、一款游戲一包煙,一臺(tái)電腦一下午。一盒泡面一壺水,一頓能管一整天。

          8、程序猿要了3個(gè)孩子,分別取名叫Ctrl、Alt 和Delete,如果他們不聽話,程序猿就只要同時(shí)敲他們一下就會(huì)好的…

          9、憲法頂個(gè)球!中國的法律都是.txt文件,不是.exe文件。 

          10、同事說,他在寫i++的時(shí)候總覺的自己寫的是 我艸.........有木有同感???? 

          11、程序員,年二十有二,始從文,連考而不中。 遂習(xí)武,練武場(chǎng)上發(fā)一矢,中鼓吏,逐之出。 改學(xué)IT,自撰一函數(shù),用之,堆棧溢出。 

          12、《桃花庵--程序員版》寫字樓里寫字間,寫字間中程序員; 程序人員寫程序,又將程序換酒錢; 酒醒只在屏前坐,酒醉還來屏下眠; 酒醉酒醒日復(fù)日,屏前屏下年復(fù)年; 但愿老死電腦間,不愿鞠躬老板前; 奔馳寶馬貴者趣,公交自行程序員; 別人笑我太瘋癲,我笑自己命太賤; 但見滿街漂亮妹,哪個(gè)歸得程序員; 

          13、有一天某程序員去買肉,要了一公斤, 拿到公平電子秤上一稱:"額。。怎么少了24克。。"

          14、檢驗(yàn)代碼質(zhì)量的唯一標(biāo)準(zhǔn) = 代碼review時(shí)罵的次數(shù) / 代碼review時(shí)間 。 

          15、殺一個(gè)程序員不需要用槍,改三次需求就可以了。

          16、C++程序員看不起C 程序員, C 程序員看不起java程序員, java程序員看不起C#程序員,C#程序員看不起美工。周末了,美工帶著妹子出去約會(huì)了,一群SX程序員還在加班。。。 

          17、問:如何生成一個(gè)隨機(jī)的字符串?答:讓新手退出VIM 。

          18、“我給你出個(gè)腦筋急轉(zhuǎn)彎,你說達(dá)芬奇密碼的上面是什么?” “這。。太難了吧。。不知道。。。” “笨!達(dá)芬奇密碼的上面就是達(dá)芬奇帳號(hào)啊,那達(dá)芬奇密碼的下面是什么?”“我。。。這。。。還是不知道。。。”“是達(dá)芬奇驗(yàn)證碼”。 

          19、隨機(jī)函數(shù)可以幫你實(shí)現(xiàn)家庭和諧: Talk(){:top word(1)="恩!"; word(2)="好的!";word(3)="然后呢?";word(4)="有道理";i=random(4); say word(i) goto top;} 

          20、程序員愛情觀:愛情就是死循環(huán),一旦執(zhí)行就陷進(jìn)去了;愛上一個(gè)人,就是內(nèi)存泄漏--你永遠(yuǎn)釋放不了;真正愛上一個(gè)人的時(shí)候,那就是常量限定,永遠(yuǎn)不會(huì)改變;女朋友就是私有變量,只有我這個(gè)類才能調(diào)用;情人就是指針用的時(shí)候一定要注意,要不然就帶來巨大的災(zāi)難。 

          21、女同學(xué)們紛紛表示,這年頭不找個(gè)程序員老公,還真是連節(jié)日低價(jià)購物權(quán)都沒了。

          22、Delphi象吉普車,什么路上都能開,卻在啥路上也開不好;PB就象卡丁車,只能在固定線路上開,到室外就有些不穩(wěn);VC象跑車,你開得起卻買不起,而且一旦發(fā)生故障,想修都找不到毛病在哪;Java象敞棚車,不管刮風(fēng)下雨還是艷陽高照,都能照開不誤;VB就是摩托車,騎的時(shí)間越長,你越痛恨它! 

          23、上聯(lián)MYSQL明月三千里 下聯(lián): XHTML.信號(hào)他媽爛! 

          24、程序員的四大理想:南極有套房,澳大利亞有群羊,全世界電腦死光光,孩兒有個(gè)娘。 

          25、有一種崩潰叫密碼輸入有誤;有一種驚慌叫做賬號(hào)異地登陸;有一種感情叫隱身對(duì)其可見;有一種誤會(huì)叫人機(jī)離線;有一種失落叫沒有訪問權(quán)限;有一種感情叫站點(diǎn)訪問失敗;有一種無奈叫bug無法復(fù)現(xiàn)。。。

          26、黑體的鋸齒,宋體的滄桑,崩潰的避頭尾集。美工永遠(yuǎn)糾結(jié)于網(wǎng)站程序員的粗獷,就像MAC永遠(yuǎn)不懂PC的憂傷。。。。

          27、程序猿追求MM不成,含淚追問:我在你眼里算什么?!MM答曰:真人版的windows優(yōu)化大師……極客哥們莫傷心,小戴安慰遞紙巾。

          28、 據(jù)說有一位軟件工程師,一位硬件工程師和一位項(xiàng)目經(jīng)理同坐車參加研討會(huì)。不幸在從盤山公路下山時(shí)壞在半路上了。于是兩位工程師和一位經(jīng)理就如何修車的問題展開了討論。硬件工程師說:“我可以用隨身攜帶的瑞士軍刀把車壞的部分拆下來,找出原因,排除故障。” 項(xiàng)目經(jīng)理說:“根據(jù)經(jīng)營管理學(xué),應(yīng)該召開會(huì)議,根據(jù)問題現(xiàn)狀寫出需求報(bào)告,制訂計(jì)劃,編寫日程安排,逐步逼近,alpha測(cè)試,beta1測(cè)試和beta2測(cè)試解決問題。” 軟件工程說:“咱們還是應(yīng)該把車推回山頂再開下來,看看問題是否重復(fù)發(fā)生。” 

          29、【高效的程序員】當(dāng)世界末日還有5分鐘就要到來的時(shí)候。程序員: 讓我們?cè)谶@最后的時(shí)刻作些什么吧!女友: 那好,讓我們?cè)谧鲎詈笠淮伟桑〕绦騿T: 那剩下的4分50秒做什么啊?

          30、【開發(fā)時(shí)間】項(xiàng)目經(jīng)理: 如果我再給你一個(gè)人,那可以什么時(shí)候可以完工?程序員: 3個(gè)月吧!項(xiàng)目經(jīng)理: 那給兩個(gè)呢?程序員: 1個(gè)月吧!項(xiàng)目經(jīng)理: 那100呢?程序員: 1年吧!項(xiàng)目經(jīng)理: 那10000呢?程序員: 那我將永遠(yuǎn)無法完成任務(wù)。

          31、一個(gè)程序員對(duì)自己的未來很迷茫,于是去問上帝。“萬能的上帝呀,請(qǐng)你告訴我,我的未來會(huì)怎樣?”上帝說:“我的孩子,你去問Lippman,他現(xiàn)在領(lǐng)導(dǎo)的程序員的隊(duì)伍可能是地球上最大的”。于是他去問Lippman。Lippman說:“程序員的未來就是駕馭程序員”。這個(gè)程序員對(duì)這個(gè)未來不滿意,于是他又去問上帝。“萬能的上帝呀,請(qǐng)你告訴我,我的未來會(huì)怎樣?”。上帝說:“我的孩子,你去問Gates,他現(xiàn)在所擁有的財(cái)產(chǎn)可能是地球上最多的”。于是他去問Gates。Gates說:“程序員的未來就是榨取程序員”。這個(gè)程序員對(duì)這個(gè)未來不滿意,于是他又去問上帝。“萬能的上帝呀,請(qǐng)你告訴我,我的未來會(huì)怎樣?”。上帝說:“我的孩子,你去問侯捷,他寫的計(jì)算機(jī)書的讀者可能是地球上最多的”。于是他去問侯捷。侯捷說:“程序員的未來就是誘惑程序員”。這個(gè)程序員對(duì)這個(gè)未來不滿意,于是他又去問上帝。“萬能的上帝呀,請(qǐng)你告訴我,我的未來會(huì)怎樣?”。上帝搖搖頭:“唉,我的孩子,你還是別當(dāng)程序員了”。

          32、面試官:“熟悉哪種語言”。應(yīng)聘者:“JAVA”。面試官:“知道什么叫類么”。應(yīng)聘者:“我這人實(shí)在,工作努力,不知道什么叫累”。面試官:“知道什么是包?”。應(yīng)聘者:“我這人實(shí)在   平常不帶包 也不用公司準(zhǔn)備了”。面試官:“知道什么是接口嗎?”。應(yīng)聘者:“我這個(gè)人工作認(rèn)真。從來不找借口偷懶”。面試官:“知道什么是繼承么”。應(yīng)聘者:“我是孤兒沒什么可以繼承的”。面試官:“知道什么叫對(duì)象么?”。應(yīng)聘者:“知道,不過我工作努力,上進(jìn)心強(qiáng),暫時(shí)還沒有打算找對(duì)象。”。面試官:“知道多態(tài)么?”。應(yīng)聘者:“知道,我很保守的。我認(rèn)為讓心愛的女人為了自已一時(shí)的快樂去墮胎是不道德的行為!請(qǐng)問這和C#有什么關(guān)系?”。

          33、IT工程師=加班狂+程序員+測(cè)試工程師+實(shí)施工程師+網(wǎng)絡(luò)工程師+電工+裝卸工+搬運(yùn)工+超人,有同感的轉(zhuǎn)走。

          34、 用一句話總結(jié)了HTML,CSS,JS的關(guān)系。HTML是名詞,JS是動(dòng)詞,CSS是形容詞和副詞。

          35、我是個(gè)程序猿,一天我坐在路邊一邊喝水一邊苦苦檢查bug。這時(shí)一個(gè)乞丐在我邊上坐下了,開始要飯,我覺得可憐,就給了他1塊錢,然后接著調(diào)試程序。他可能生意不好,就無聊的看看我在干什么,然后過了一會(huì),他幽幽的說,這里少了個(gè)分號(hào)。。。分號(hào)。。。分號(hào)。。。

          36、女友對(duì)程序員說:“紫禁城占得地方好大呀!”程序員:“殺死那個(gè)子進(jìn)程……”

          37、從前有個(gè)全國管理系統(tǒng),是孫中山做的設(shè)計(jì),老蔣做的實(shí)現(xiàn),結(jié)果老毛寫了個(gè)病毒,趁著日本黑客對(duì)系統(tǒng)做攻擊的當(dāng)口,拿到了管理員權(quán)限,把原來那批程序員給隔離了。老鄧接手以后,重構(gòu)代碼,出了個(gè)2.0版,為了開發(fā)速度,遺留了一堆BUG沒處理。人們紛紛質(zhì)疑:是不是核心構(gòu)架太單一,雙核會(huì)不會(huì)好點(diǎn)?

          38、一程序員家的水管壞了,他打電話叫來一個(gè)水管工修理。 水管工鼓搗了一個(gè)小時(shí),終于把管子修好了,他遞給程序員一張600元的帳單。 “600元!”程序員憤怒地說:“我當(dāng)程序員一天都賺不了這么多錢!” “是啊。”水管工平靜地說,“我當(dāng)程序員的時(shí)候也是。”

          39、十年前,女:“對(duì)不起,我不會(huì)喜歡你的,你不要再堅(jiān)持了,就好比讓 Linux 和 Windows 同時(shí)運(yùn)行在一臺(tái)PC機(jī)上,可能嗎?”男生聽后默默走開,十年后,在一次虛擬技術(shù)大會(huì)上,我聽到一名虛擬技術(shù)開發(fā)程序員給我講述了這個(gè)故事。

          40、程序猿問程序媛:"為什么要離開我,我做得還不夠好嗎?" 媛說:"別傻了,我們根本就是兩個(gè)世界里的人,就像在JS里永遠(yuǎn)都無法調(diào)用JAVA類一樣,我們之間也是不可能的。" 猿沉默了很久,轉(zhuǎn)身離開了。一個(gè)月之后,他在開源社區(qū)公布了dwr的完整代碼。

          41、【程序員被提bug之后的反應(yīng)】1.怎么可能; 2.在我這是好的,不信你來看看; 3.真是奇怪,剛剛還好好的; 4.肯定是數(shù)據(jù)問題; 5.你清下緩存試試; 6.重啟下電腦試試; 7.你裝的什么版本的類庫(jdk) 8.這誰寫的代碼; 9.尼瑪怎么還在用360安全 瀏覽器 ; 10.用戶不會(huì)像你這么操作的。

          42、敲一夜代碼,流兩行老淚;用三種語言,唯四肢受罪 ; 待五更雞鳴,遇驟雨初歇;遂登門而去,佇十里長亭;欲望穿淚眼,無如意郎君;借微薄助力,愿尋得佳偶;成比翼雙鳥,乃暢想云端;卷情網(wǎng)之內(nèi),做爬蟲抓?。粸檫B理桂枝,容數(shù)據(jù)分析;思千里子規(guī),助框廣天地; 念茫茫人海,該如何尋覓?

          43、早晨一女生抱著一堆書進(jìn)了閱覽室,結(jié)果警報(bào)響了,大媽讓女生看看是哪本書把警報(bào)弄響了,那女生把書倒出來,準(zhǔn)備一本一本的測(cè)。大媽見狀急了,把書分成兩份,第一份過了一下,響了。又把這一份分成兩份接著測(cè),三回就找到了,大媽用鄙視的眼神看著女生,仿佛在說O(n)和O(log2n)都分不清。

          44、發(fā)現(xiàn)程序員經(jīng)常熬夜有三個(gè)弊端:第一,記憶力越來越差;第二,數(shù)數(shù)經(jīng)常會(huì)數(shù)錯(cuò);第四,記憶力越來越差。

          45、醫(yī)院回來的程序猿一臉的苦逼樣。程序媛:怎么了?程序猿:得了類風(fēng)濕性關(guān)節(jié)炎了,我怕會(huì)遺傳給下一代啊。程序媛:誰說類風(fēng)濕性關(guān)節(jié)炎能遺傳的?程序猿一臉詫異:類不是繼承的嗎?

          46、知道JAVA程序員和C程序員的差別嗎?食堂里,吃完飯就走的是JAVA程序員,吃完飯還要自己 收拾的那就是是C程序員。至于為什么會(huì)這樣、大家都明白(因?yàn)镴AVA自帶垃圾回收機(jī)制、、、C需要手動(dòng)釋放內(nèi)存)←這就是原因

          47、計(jì)算機(jī)系的男同學(xué)追班里一女同學(xué),結(jié)果此女總是躲躲閃閃。 男的看沒戲,就另找了一個(gè)去追,結(jié)果這女的不滿意了,質(zhì)問這男的為啥拋棄她。 男的問:“請(qǐng)教一個(gè)電腦問題,如果你點(diǎn)擊一個(gè)程序,總是提示‘沒有響應(yīng)’,怎么辦?” 女的說:“馬上結(jié)束任務(wù)。” 男的:“對(duì),我也是這樣想的。”

          48、一個(gè)程序員的吐槽:即要被當(dāng)做修電腦的,也要被當(dāng)作做網(wǎng)站的;即要被當(dāng)作殺毒的,也要被當(dāng)作盜號(hào)的。我要告訴大家,其實(shí)我們只是寫代碼的。

          49、如果一個(gè)足球界的人“猝死”了,會(huì)被懷疑和賭球有關(guān);如果一個(gè)官員“猝死”了,會(huì)被懷疑和貪腐有關(guān);如果一個(gè)農(nóng)民"猝死"了,會(huì)被懷疑和拆遷有關(guān);而如果一個(gè)程序員猝死了,那他真的猝死了。

          50、老婆是操作系統(tǒng),一但安裝卸載十分麻煩;小秘是桌面,只要你有興趣可以天天更換;情人是互聯(lián)網(wǎng),風(fēng)光無限花錢不斷;小姐是盜版軟件,用時(shí)記著先殺毒。

          51、前臺(tái)美女三寶:你好,找誰,倒飲料。產(chǎn)品經(jīng)理三寶:山寨,改版,再推倒。項(xiàng)目經(jīng)理三寶:進(jìn)度,流程,做報(bào)表。團(tuán)隊(duì)經(jīng)理三寶:團(tuán)建,開會(huì),評(píng)績效。數(shù)據(jù)分析師三寶:SQL,Excel,PPT。人事經(jīng)理三寶:畫餅,忽悠,挖墻腳。設(shè)計(jì)師三寶:修改,重做,飛機(jī)稿。程序員三寶:悶騷,加班,修電腦。

          52、對(duì)于程序員來說、沒老婆不悲催。悲催的是、沒老婆、控制臺(tái)還不停的提示你Error:could not find the object

          53、假如生活欺騙了你,不要悲傷不要心急。《代碼大全》會(huì)一直陪伴著你……

          54、有時(shí)候真覺得有些事情如同char*一般,從開始就注定,無法改變。

          55、洛陽親友如相問,就說我在敲代碼。

          56、"如果你ctrl+alt+del,蹦出任務(wù)管理器,你從上到下掃一眼,所有的進(jìn)程你都認(rèn)識(shí),知道他們是干什么的,并且知道關(guān)掉有什么后果,而且你還能從CPU和內(nèi)存占用的數(shù)字跳動(dòng)上清楚的知道電腦現(xiàn)在什么狀態(tài),那么你應(yīng)該沒有女朋友"...........你妹啊

          57、用IE6的吃方便面都沒有調(diào)料包,你知道不知道......

          58、普通青年用IDE(Visual Studio, Eclipse, XCode);文藝青年用VIM, Emacs;二逼青年將IDE設(shè)置成VIM模式。

          59、程序員換IDE相當(dāng)于搬家,換主力語言相當(dāng)于改嫁,換操作系統(tǒng)相當(dāng)于參加FBI證人保護(hù)計(jì)劃…

          60、有兩個(gè)程序員釣魚,其中一個(gè)釣到一條美人魚,這個(gè)美人魚上半身是美女,下半身是魚,于是這個(gè)程序員 就吧她放了,另一個(gè)問他:Why,他回答說:沒有API

          61、阿里小米皆自主,百度排名最公平;京東全網(wǎng)最低價(jià),當(dāng)當(dāng)愛國很理性;用戶體驗(yàn)看新浪,網(wǎng)易從來少憤青;豆瓣從來不約炮,人人分享高水平;從不抄襲數(shù)騰訊, 開放安全三六零。

          62、編程夜當(dāng)午,手握小滑鼠。誰知編程辛,行行皆“心”苦;頭昏不覺曉,使勁揉眼角。夜夜太辛苦,睡眠知多少;

          63、熱火朝天的辦公室,一精壯青年一邊啃著饅頭,一邊看著眼前產(chǎn)品,愁眉緊鎖的他陷入了沉思:產(chǎn)品下一步應(yīng)該怎么走?如何保證代碼質(zhì)量?如何縮短項(xiàng)目時(shí)間?如何控制項(xiàng)目成本?一個(gè)個(gè)難題需要他思索,抉擇。此時(shí),傳來項(xiàng)目經(jīng)理的吆喝:“程旭元,先別敲代碼了!給我修下電腦……”

          64、原來《人月神話》不是本奇幻小說! 原來《代碼大全》不是一堆開源代碼! 原來《鳥哥的Linux私房菜》不是教你做菜! 原來《邊城》不是教你寫代碼的! 原來《深入淺出HTML》不是教你How to Make Love

          65、文藝程序員寫代碼追求讓別人看懂,普通程序員追求讓自己看懂,2B程序員則追求讓編譯器能看懂;半年后看自己當(dāng)初寫的代碼,文藝程序員不知道是自己寫的但很容易看懂,普通程序員知道是自己寫的但是不太容易看懂,2B程序員埋頭看了半天后拍著桌子吼到:“這是哪個(gè)SB寫的程序!”

          66、我真的想讓這個(gè)世界變得更好,但是他們不給我源代碼……

          67、【夢(mèng)醒時(shí)分(程序員版)】你說你寫了不該寫的代碼,搞得程序全是bug。你說你定義了不該定義的接口,架構(gòu)只能重寫。你說你走查過了所有代碼,找不到正確的地方。你說你感到萬分沮喪,甚至開始不打算編程。

          68、曾經(jīng)有很多次機(jī)會(huì)可以避免bug,將項(xiàng)目按時(shí),保質(zhì)保量交付給客戶,但我沒有珍惜,等到世界末日,我才意識(shí)到,程序員界最痛苦的事莫過于此。如果瑪雅人能給我一次重新選擇的機(jī)會(huì),讓22號(hào)的太陽依然升起,我會(huì)重新做程序員,用代碼改變世界!

          69、據(jù)一位不愿透露姓名的程序員說,基本上所有客戶的所有要求都能總結(jié)為下面這樣一幅對(duì)聯(lián),上聯(lián):簡單易用界面好,下聯(lián):穩(wěn)定高效花錢少,橫批:立馬就要。

          70、某女:你能讓微博的人都吵起來,我今晚就跟你走。 某軟件工程師:PHP是最好的語言! 某論壇炸鍋了,各種吵架...。某女:服了你了,我們走吧,你想干啥都行。某軟件工程師:今天不行,我一定要說服他們,PHP是最好的語言。

          71、“我愛你”三個(gè)字,講出來只要三秒鐘,解釋要三小時(shí),證明卻要一輩子。 “bug”三個(gè)字母,發(fā)現(xiàn)需要三秒,找到需要三小時(shí),debug卻要一輩子…...

          72、生活不僅只是敲代碼,還有...調(diào)bug..。

          73、本人擅長Ai、Fw、Br、Ae、Pr、Id、Ps等軟件的安裝與卸載,精通CSS、JavaScript、PHP、C、C++、C#、Java、Ruby、Perl、Lisp、Python、Objective-C、ActionScript等單詞的拼寫,熟悉Windows、Linux、Mac OS、IOS、Android等系統(tǒng)的開關(guān)機(jī),求一份月薪上萬的工作!

          74、剛在公交車上,一小朋友拿著一本英語書,問她爸爸:xxxxxx for 100 years,這里為什么用for呢?她爸說:你看,100 years時(shí)間很長很長,要循環(huán)100次才行,當(dāng)然用for呀!我聽到后,恍然大悟!

          78、男朋友寫代碼不理我,于是我悄悄改掉了web.xml的一個(gè)配置,他搞了兩天都沒調(diào)通,我告訴了他,結(jié)果他要和我分手,我很傷心,但他的朋友告訴我,他沒砍死你才說明他真的愛你…” “樓主別tm編了,程序員哪來的女朋友!” “SB,誰告訴你我是女的了。”

          79、產(chǎn)品經(jīng)理被綁,蒙眼,驚問:“想干什么?”,對(duì)方不語,鞭笞之,產(chǎn)品經(jīng)理求饒:“別打,要錢?”,又一鞭,“十萬夠不?”,又一鞭,“一百萬?”,又一鞭。產(chǎn)品經(jīng)理崩潰:“你們TMD到底要啥?”“要什么?我?guī)湍阕鲰?xiàng)目,寫代碼的時(shí)候也很想知道你TMD到底想要啥!”

          80、某男是程序員,每天半夜三更才回家。某女抱怨:“你就不能提早點(diǎn)回家么?” 某男:“好,一定。” 于是下次某男一直寫代碼到天亮提著油條豆?jié){才回家。

          81、有人說,女程序員再淑女,一旦編程就會(huì)暴露自己的身份,習(xí)慣性的把前額的頭發(fā)往上捋,露出大大的額頭。因?yàn)镃PU高速運(yùn)作時(shí)需要良好的散熱。

          82、兩個(gè)程序員在聊天:“我昨天碰到個(gè)辣妹。我把她帶回家,馬上就開始如饑似渴地親吻,她就坐在我的鍵盤上,然后……” “你家里也有臺(tái)電腦?啥配置???”

          83、【如何夸程序員?】通用:你這代碼寫得真好看??銫程序員:你這代碼不看注釋就能懂,寫得真好??銻uby程序員:我艸,太神奇了,你怎么做到的!夸Perl程序員:這個(gè)正則表達(dá)式碉堡了。夸Python程序員:Pythonic!夸Java程序員:你寫的代碼一點(diǎn)都不像Java!

          84、昨晚去KTV找小姐。 美女:請(qǐng)問先生需要什么類型的? 我:學(xué)過編程的都給我出來! 美女:我就是啊! 我:兩個(gè)小時(shí),把Bug給找出來,我著急要! 美女:客官請(qǐng)自重,小女子賣身不賣藝……

          85、某程序猿,一直不為女朋友家人所待見。過完年回來,突然宣布說他們準(zhǔn)備今年結(jié)婚,這讓人很是詫異女方家里何以松口了。本著八卦的心態(tài)打聽之后才知道——程序猿春節(jié)前自己搞了個(gè)小軟件,把女方家的七姑媽、八大姨的春運(yùn)火車票都給解決了……他真得感謝12306!

          86、對(duì)于各種凌亂的電腦問題,其他行業(yè)的人,以為程序員們什么都會(huì);程序員中的女程序員,以為男程序員什么都會(huì);男程序員中一般程序員,以為技術(shù)好的程序員什么都會(huì);技術(shù)好的程序員每次都在網(wǎng)上苦苦找答案。。。

          87、程序員跟產(chǎn)品經(jīng)理一起看電視。每個(gè)節(jié)目看到一半程序員就換臺(tái),看到一半就換臺(tái),幾次之后產(chǎn)品經(jīng)理終于忍無可忍的咆哮:老子剛看出點(diǎn)意思你就換、剛看出點(diǎn)意思你就換,到底還讓不讓人看啦?!程序員淡定的盯著電視道:你半路改需求的時(shí)候我可沒吱過聲!

          88、菜鳥:“我該怎么學(xué)習(xí)WEB編程呢?”大牛:“WEB編程就是一個(gè)程序員帶著兩個(gè)MM(MSSQL與MYSQL),玩3P(JSP,PHP,ASP),然后學(xué)著How to make love(HTML)..”

          89、兩程序員向同一個(gè)MM求愛,MM說"去環(huán)游世界后再來找我!"。碼農(nóng)A立即收拾行李出發(fā)。碼農(nóng)B繞MM一圈,然后說"hello world!",立即感動(dòng)了MM。其實(shí)他只是習(xí)慣在做任何新事情前先確定hello world能跑通而已。

          90、【世界上最沒用的幾句話】 1、警察:不要跑! 2、國足:必勝! 3、老師:同學(xué)們不要睡了! 4、病人:醫(yī)生,您輕點(diǎn)兒! 5、父母:孩子,不要鬧了 !6、罪犯:我是冤枉??!7、女人:不要嘛!8、男人:我發(fā)誓!9、程序員:這個(gè)不能實(shí)現(xiàn)。

          原文連接:http://blog.sina.com.cn/s/blog_883c46a60101a8ex.html

          posted @ 2013-05-19 23:27 管先飛 閱讀(382) | 評(píng)論 (0)編輯 收藏

          1、Controller:
                         Map<String, Object> rootMap = new HashMap<String, Object>();
          ootMap.put("list",getMusicPublisList(page.getList()));
          String templateName="appweb/music/index.ftl";
            Render appRender=new AppFreeMarkerRender(rootMap,templateName);
            this.render(appRender);
          2、AppFreeMarkerRender(在FreeMarkerRender上修改):
          package com.microcorecn.common.utils;
          import java.io.PrintWriter;
          import java.util.Enumeration;
          import java.util.HashMap;
          import java.util.Locale;
          import java.util.Map;
          import java.util.Properties;
          import javax.servlet.ServletContext;
          import com.jfinal.render.Render;
          import com.jfinal.render.RenderException;
          import freemarker.template.Configuration;
          import freemarker.template.ObjectWrapper;
          import freemarker.template.Template;
          import freemarker.template.TemplateException;
          import freemarker.template.TemplateExceptionHandler;
          /**
           * FreeMarkerRender.
           */
          public class AppFreeMarkerRender extends Render {
          private static final long serialVersionUID = -7649769283048920381L;
          private transient static final String encoding = getEncoding();
          private transient static final String contentType = "text/html; charset=" + encoding;
          private String templateName;
          private Map<String, Object>  rootMap;
          public AppFreeMarkerRender(Map<String, Object> rootMap, String templateName) {
            this.templateName=templateName;
            this.rootMap=rootMap;
          }
              
          @SuppressWarnings({"unchecked", "rawtypes"})
          public void render() {
          response.setContentType(contentType);
                  Enumeration<String> attrs = request.getAttributeNames();
          Map root = new HashMap();
          while (attrs.hasMoreElements()) {
          String attrName = attrs.nextElement();
          root.put(attrName, request.getAttribute(attrName));
          }
                   root.putAll(rootMap);
                   
          PrintWriter writer = null;
                  try {
          Template template = FreemarkerUtil.getAppConfiguration().getTemplate(this.templateName);
          writer = response.getWriter();  //一邊請(qǐng)求,一邊render
          template.process(root, writer); // Merge the data-model and the template
          } catch (Exception e) {
          throw new RenderException(e);
          }
          finally {
          if (writer != null)
          writer.close();
          }
          }
          }
          3、FreemarkerUtil :
          package com.microcorecn.common.utils;
          import java.io.BufferedWriter;
          import java.io.File;
          import java.io.FileOutputStream;
          import java.io.IOException;
          import java.io.OutputStreamWriter;
          import java.io.StringWriter;
          import java.io.Writer;
          import java.util.Enumeration;
          import java.util.HashMap;
          import java.util.Map;
          import javax.servlet.http.HttpServletRequest;
          import javax.servlet.http.HttpServletResponse;
          import com.jfinal.kit.PathKit;
          import com.jfinal.render.FreeMarkerRender;
          import freemarker.cache.FileTemplateLoader;
          import freemarker.template.Configuration;
          import freemarker.template.DefaultObjectWrapper;
          import freemarker.template.Template;
          /**
           * freemarker生成html的工具類
           * 
           * @author Administrator
           * 
           */
          public class FreemarkerUtil {
          //保存所有參數(shù),js路徑,cs路徑等
          private static Map<String, Object> releaseParams = new HashMap<String, Object>();
          static{
          //releaseParams.put("csspath", "");
          }
          //配置
          private static Configuration config = null;
          private static Configuration appConfig = null;
          /**
          * appConfig配置所有參數(shù)
          * 重寫freemarker中的  reader方法,讀取該配置文件
          * @return
          */
          public static Configuration getAppConfiguration()
          {
          if(appConfig == null)
          {
          //從freemarker中獲取所有配置
          appConfig = (Configuration)FreeMarkerRender.getConfiguration().clone();
          try {
          //設(shè)置模板路徑
          /* config.setDirectoryForTemplateLoading(new File(PathKit.getWebRootPath()));
          config.setObjectWrapper(new DefaultObjectWrapper());*/
          appConfig.setDirectoryForTemplateLoading(new File(PathKit.getWebRootPath()+"/WEB-INF/views/"));
          appConfig.setObjectWrapper(new DefaultObjectWrapper());   
          } catch (IOException e) {
          // TODO log
          }
          }
          return appConfig;
          }
          posted @ 2013-05-19 14:16 管先飛 閱讀(4965) | 評(píng)論 (2)編輯 收藏

          1、<數(shù)據(jù)庫用戶>
          本地用戶
            GRANT ALL PRIVILEGES ON *.* TO 'user_name'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
            注:第一個(gè)*為數(shù)據(jù)庫名
          所有用戶(有的版本不包含本地用戶,還有加上上面一名)
           GRANT ALL PRIVILEGES ON *.* TO 'user_name'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
          </數(shù)據(jù)庫用戶>

          2、<數(shù)據(jù)庫導(dǎo)出>
          導(dǎo)出數(shù)據(jù)結(jié)構(gòu)
             C:/Program Files/MySQL/MySQL Server 5.5/bin/mysqldump -uroot -proot -d tienal_admin > c:/tienal_admin.sql   
          導(dǎo)出數(shù)據(jù)結(jié)構(gòu)與數(shù)據(jù)
             C:/Program Files/MySQL/MySQL Server 5.5/bin/mysqldump -uroot -proot tienal_admin > c:/tienal_admin.sql
             </數(shù)據(jù)庫導(dǎo)出>

          3、<數(shù)據(jù)庫導(dǎo)入>
          從MySQL命令行
              use tienal_admin;
              source E:/PeaceWork/Project/天籟音樂/原始資料/tienal_admin/misc/sql.sql;
          直接運(yùn)行
             C:/Program Files/MySQL/MySQL Server 5.5/bin/mysql -uroot -proot tienal_admin < c:/tienal_admin.sql    
          </數(shù)據(jù)庫導(dǎo)入>

          posted @ 2013-05-19 13:57 管先飛 閱讀(1876) | 評(píng)論 (0)編輯 收藏

          主站蜘蛛池模板: 太原市| 利津县| 邵东县| 卢龙县| 舟曲县| 百色市| 慈溪市| 固原市| 枣庄市| 伊宁县| 高密市| 浪卡子县| 拉孜县| 垣曲县| 固始县| 万宁市| 札达县| 临洮县| 青海省| 台北县| 泾川县| 双柏县| 阳山县| 电白县| 项城市| 东台市| 偏关县| 马公市| 浦北县| 吉安市| 芮城县| 珠海市| 盐城市| 青铜峡市| 文昌市| 沙田区| 建瓯市| 城口县| 沙雅县| 海盐县| 九江县|