GithubHelp home page GithubHelp logo

fanwentao-felix / standardprojet4javaweb Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 9.28 MB

Java web 项目标准,规范

Java 96.48% Scala 3.34% Batchfile 0.07% Shell 0.05% JavaScript 0.04% Python 0.03%

standardprojet4javaweb's Introduction

project standard

standard structure for Java Web Application.
Java web 项目标准,规范

制定编码规范

  • 错误码定义:BusinessException, RequestException, ValidationException

业务要点记录,业务名,范围,对接人

日志按业务划分

README文件:注明系统间代码耦合的地方,具体类

开发不仅仅只是应付需求,考虑代码扩展性和安全隐患等方面也是工作量,也很有必要

留意那些包路径或方法事务切面了

写可测试可监控的代码

  1. 添加依赖包需要用eclipse查看Resolved Dependencies,查看最终依赖有没有变(若依赖有问题,字节码是在加载使用到的时候才会报错,classload机制)
  2. debug log 需要加 if(logger.isDebugEnabled()),隔离不必要的操作,比如预编译之类的问题,slf4j也一样。
  3. 参数绝对不能传中文,避免以后埋坑
  4. 代码文档规范:http://www.importnew.com/16459.html
  5. @Deprecated标识废弃
  6. 新建类时,查看该类所属的包是否被AOP,查看xml文件确认
<aop:config>
		<aop:pointcut id="daoMethodsExp"
			expression="execution(* com.kxw.dao.service.impl.*.*(..))" />
		<aop:advisor advice-ref="txAdvice" pointcut-ref="daoMethodsExp" />
</aop:config>
  1. <c:if> 是服务端语言,不能写在js中,若需要传参,可用<input> hidden的方式
  2. js: 条件语句:var str = "abc + "false ? "" : "kxw";
  3. 定义不抛异常不代表不会隐性给你抛异常,要加try catch!!!
  4. remove web.xml : WebApplicationInitializer http://www.javabeat.net/webapplicationinitializer-spring-mvc/ http://www.javacodegeeks.com/2014/10/spring-webapplicationinitializer-and-applicationcontextinitializer-confusion.html config-api project
  5. 提交数据不能用get, 1.不安全 2.容易在浏览器地址栏造成历史纪录,造成误提交
  6. 解决maven依赖,如果ide中对某一个类有多个jar包,应该排除依赖保持一个版本,使用<Execludes>,有些隐形依赖,在项目中搜索不出来,可使用mvn dependency:tree来查看.
  7. 工具类封装,如HttpUtils,JsonUtils。方便以后替换或升级底层的实现,如究竟是使用jackson还是fastjson。
  8. Controller只能写一些不能复用的代码。

wiki

  1. 记录接口是否废弃,调用方等信息

  1. log4j.jsp
  2. version.jsp jsp中写java代码读取文件
  3. gradle
  4. scala
  5. 在页面中读取文件(1).采用js(读本地文件)(2).采用jsp(写java代码)

SonarQube idea plugin


Tools http://tongji.baidu.com/web/welcome/products http://tongji.baidu.com/web/welcome/login?qq-pf-to=pcqq.c2c

standardprojet4javaweb's People

Contributors

kingson4wu avatar

Stargazers

 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.