当前位置: 首页 > news >正文

婚庆公司网站建设得多少钱购买链接平台

婚庆公司网站建设得多少钱,购买链接平台,wordpress视频自适应代码,网站开发所需要的书籍JFinal 是基于 Java 语言的极速 WEB ORM 框架,其核心设计目标是开发迅速、代码量少、学习简单、功能强大、轻量级、易扩展、Restful。 官方文档:http://www.jfinal.com/download?filejfinal-1.8-manual.pdf 官网:http://www.jfinal.com/man 1.创建工…

JFinal 是基于 Java 语言的极速 WEB + ORM 框架,其核心设计目标是开发迅速、代码量少、学习简单、功能强大、轻量级、易扩展、Restful。
官方文档:http://www.jfinal.com/download?file=jfinal-1.8-manual.pdf
官网:http://www.jfinal.com/man

1.创建工程、准备Jar包
创建一个Maven项目,然后Pom中导入JFinal等Jar包。
Pom.xml

  <dependencies><dependency><groupId>com.jfinal</groupId><artifactId>jfinal</artifactId><version>1.9</version></dependency><dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>3.0.1</version><scope>provided</scope><optional>true</optional></dependency><dependency><groupId>freemarker</groupId><artifactId>freemarker</artifactId><version>2.3.9</version></dependency><!-- EHCACHE begin --><dependency><groupId>net.sf.ehcache</groupId><artifactId>ehcache</artifactId><version>2.8.1</version></dependency><dependency><groupId>c3p0</groupId><artifactId>c3p0</artifactId><version>0.9.1.2</version></dependency><!-- Logging with SLF4J & LogBack --><dependency><groupId>org.slf4j</groupId><artifactId>slf4j-api</artifactId><version>1.7.5</version><scope>compile</scope></dependency><dependency><groupId>ch.qos.logback</groupId><artifactId>logback-classic</artifactId><version>1.0.13</version><scope>runtime</scope></dependency><!-- mysql --><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>5.1.34</version></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>3.8.1</version><scope>test</scope></dependency></dependencies>

2.创建JFinal核心配置类
JFinal属于配置极少,基本属于无XML零配置的框架,它的所有配置都在一个继承JFinalConfig的核心配置类中。
Config.java

public class Config extends JFinalConfig {@Overridepublic void configConstant(Constants me) {}//配置 JFinal 常量值@Overridepublic void configHandler(Handlers me) {}@Overridepublic void configInterceptor(Interceptors me) {}@Overridepublic void configPlugin(Plugins me) {}@Override public void configRoute(Routes me) {}//来配置 JFinal 访问路由
}

3.修改Web.xml
将如下内容添加至 web.xml

<filter><filter-name>jfinal</filter-name><filter-class>com.jfinal.core.JFinalFilter</filter-class><init-param><param-name>configClass</param-name><param-value>com.langmy.music.config.Config</param-value></init-param></filter><filter-mapping><filter-name>jfinal</filter-name><url-pattern>/*</url-pattern>
</filter-mapping>

4.创建Controller访问第一个页面

(1) 创建IndexController

public class IndexController extends Controller{public void index(){renderFreeMarker("/index.html");//FreeMarker是模板引擎,访问普通的Html页面也可以。}
}

Controller需要继承JFinal的Controller类。

(2) 加入路由
在Config中加入IndexController的路由

public void config(Routes me) {me.add("/", IndexController.class);
}

路由规则如下:
这里写图片描述
controllerKey指的是是config中配置的”/”,然后在默认情况下会访问Controller会访问index()方法。

在保证Webapp下有index.html的情况下,打开浏览器打入http://localhost:8080/[项目名称]/ 就能进入index.html页面.

(3) ActionKey
JFinal 在以上路由规则之外还提供了 ActionKey 注解,可以打破原有规则。
在IndexController加入两个方法,然后IndexController变成如下:

public class IndexController extends Controller{public void index(){renderFreeMarker("/index.html");}public void showText(){renderText("Show Text");}@ActionKey("actionKey")public void testActionKey(){renderText("Test ActionKey");}
}

打开浏览器分别访问http://localhost:8080/[项目名称]/showText和http://localhost:8080/[项目名称]/actionKey可以看到页面如下:
这里写图片描述
这里写图片描述

5.路由拆分
JFinal 路由还可以进行拆分配置,这对大规模团队开发特别有用,以下是代码示例:

public class FrontRoutes extends Routes {public void config() {add("/", IndexController.class);}
}
public class AdminRoutes extends Routes{@Overridepublic void config() {// TODO 写后台的路由}
}
public class Config extends JFinalConfig {.....@Overridepublic void configRoute(Routes me) {me.add(new FrontRoutes());me.add(new AdminRoutes());}
}

如上三段代码, FrontRoutes 类中配置了系统前端路由, AdminRoutes 配置了系统后端路由,
Config.configRoute(…)方法将拆分后的这两个路由合并起来。使用这种拆分配置不仅
可以让 Config文件更简洁,而且有利于大规模团队开发,避免多人同时修改Config版本冲突。

6.数据库操作

(1) 新建数据库
新建mysql数据库testJFinal,新建一个表user(id,user_acc,name)。

(2) 新建Model类

public class User extends Model<User>{public static final User dao = new User();
}

(3) 加入数据库操作插件与User与表user映射:

public class Config extends JFinalConfig {@Overridepublic void configPlugin(Plugins me) {//C3p0数据源插件C3p0Plugin cp = new C3p0Plugin("jdbc:mysql://localhost/testJFinal","root", "19930815");me.add(cp);// ActiveRecord插件ActiveRecordPlugin arp = new ActiveRecordPlugin(cp);me.add(arp);arp.addMapping("user", User.class);}
}

ActiveRecord 是 JFinal 最核心的组成部分之一,通过 ActiveRecord 来操作数据库,将极大地减少代码量,极大地提升开发效率。ActiveRecord 是作为 JFinal 的 Plugin 而存在的,所以使用时需要在 JFinalConfig 中配置ActiveRecordPlugin。

(4) 数据库操作
在IndexController中加入方法testDB。

public class IndexController extends Controller{....public void testDB() {List<User> users = User.dao.find("select * from user");
//      List<User> users = User.dao.find("select * from user where id=?",2);//分页查询
//      Page<User> users = User.dao.paginate(1, 10, "select *","from user where id=?",2);for(User user :users.getList())              System.out.println(user.toString()+user.getStr("user_acc"));}//新增一条User数据/*User user = new User();user.set("user_acc", "accNew");user.set("name", "nameNew");boolean flag = user.save();System.out.println(flag);*/setAttr("user", users);renderFreeMarker("/test.html");}
}

以下是官方文档中对于数据库操作的一些示例:

// 创建name属性为James,age属性为25的User对象并添加到数据库
new User().set("name", "James").set("age", 25).save();
// 删除id值为25的User
User.dao.deleteById(25);
// 查询id值为25的User将其name属性改为James并更新到数据库
User.dao.findById(25).set("name", "James").update();
// 查询id值为25的user, 且仅仅取name与age两个字段的值
User user = User.dao.findById(25, "name, age");
// 获取user的name属性
String userName = user.getStr("name");
// 获取user的age属性
Integer userAge = user.getInt("age");
// 查询所有年龄大于18岁的user
List<User> users = User.dao.find("select * from user where age>18");
// 分页查询年龄大于18的user,当前页号为1,每页10个user
Page<User> userPage = User.dao.paginate(1, 10, "select *", "from user
where age > ?", 18);

7.ehcache缓存加入

(1) 加入EhCachePlugin
EhCachePlugin 是 JFinal 集成的缓存插件,通过使用 EhCachePlugin 可以提高系统的并发访问速度。
在Config的configPlugin中加入:
me.add(new EhCachePlugin());

(2) 配置文件ehcache.xml

<?xml version="1.0" encoding="UTF-8"?>
<ehcache updateCheck="false" name="defaultCache"><diskStore path="java.io.tmpdir/music/ehcache/default" /><!-- DefaultCache setting. --><defaultCache maxEntriesLocalHeap="100" eternal="false" timeToIdleSeconds="300" timeToLiveSeconds="600"overflowToDisk="true" maxEntriesLocalDisk="100000" maxElementsInMemory="500" /> <cache name="userList" maxElementsInMemory="150" eternal="false" timeToLiveSeconds="3600"timeToIdleSeconds="360" overflowToDisk="true"/>
</ehcache>

ehcache中各种属性的配置请参考下一篇Blog 《ehcache 简单配置》。

(2) 缓存注解加入

CacheInterceptor 可以将 action 所需数据全部缓存起来, 下次请求到来时如果 cache 存在则
直接使用数据并 render,而不会去调用 action。此用法可使 action 完全不受 cache 相关代码所
污染,即插即用,以下是示例代码:
EvictInterceptor 可以根据 CacheName 注解自动清除缓存。

在相应需要加入缓存的方法上加入:

@Before(CacheInterceptor.class)
@CacheName("userList")

需要清除缓存的方法上加入:

@Before(EvictInterceptor.class)
@CacheName("userList")

我在testDB中注释了save方法,只剩下find方法,加入缓存注解。
在浏览器第一次访问这个方法的时候会调用方法加入缓存,第二次就不会再进方法。

8.LogBack日志加入

(1) 加入配置文件logback.xml

<?xml version="1.0" encoding="UTF-8"?>
<!-- configuration file for LogBack (slf4J implementation)
See here for more details: http://gordondickens.com/wordpress/2013/03/27/sawing-through-the-java-loggers/ -->
<configuration scan="true" scanPeriod="60 seconds"><contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator"><resetJUL>true</resetJUL></contextListener><!-- To enable JMX Management --><jmxConfigurator/><appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">  <!-- 日志输出编码 -->    <Encoding>UTF-8</Encoding>     <layout class="ch.qos.logback.classic.PatternLayout">     <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->   <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n     </pattern>     </layout>     </appender><!-- 无用日志禁用 --><root level="DEBUG">     <appender-ref ref="STDOUT" />     <appender-ref ref="FILE" />     </root> 
</configuration>

(2) 使用日志

//在类中加入:
public static Logger LOG  = LoggerFactory.getLogger(IndexController.class);
//在方法中加入
if(LOG.isDebugEnabled()){LOG.debug(users.toString());}

源代码下载地址:https://github.com/crazyBugLzy/JFinalLearn


文章转载自:
http://dinncosaxicoline.tqpr.cn
http://dinncomidlife.tqpr.cn
http://dinncoepigraphy.tqpr.cn
http://dinncocontrasuggestible.tqpr.cn
http://dinncotetranitromethane.tqpr.cn
http://dinncoameerate.tqpr.cn
http://dinncoanthomania.tqpr.cn
http://dinncostopover.tqpr.cn
http://dinncorainstorm.tqpr.cn
http://dinncogibli.tqpr.cn
http://dinncojacobus.tqpr.cn
http://dinncobrutalitarian.tqpr.cn
http://dinncohospltaler.tqpr.cn
http://dinncooppugn.tqpr.cn
http://dinncovictrola.tqpr.cn
http://dinncofuzzball.tqpr.cn
http://dinncoseconde.tqpr.cn
http://dinncopionic.tqpr.cn
http://dinncodichotic.tqpr.cn
http://dinncospottiness.tqpr.cn
http://dinncoaquaria.tqpr.cn
http://dinncolegitimist.tqpr.cn
http://dinncocyclopaedic.tqpr.cn
http://dinncoisotropism.tqpr.cn
http://dinncoklunky.tqpr.cn
http://dinncofivescore.tqpr.cn
http://dinncoluncheon.tqpr.cn
http://dinncofaustina.tqpr.cn
http://dinncophilander.tqpr.cn
http://dinncotactful.tqpr.cn
http://dinncoeuphausiacean.tqpr.cn
http://dinncoimportation.tqpr.cn
http://dinncosociogeny.tqpr.cn
http://dinncoprep.tqpr.cn
http://dinncoduplicability.tqpr.cn
http://dinncosorry.tqpr.cn
http://dinncooutpost.tqpr.cn
http://dinncovirilescence.tqpr.cn
http://dinncotrichogen.tqpr.cn
http://dinncokaraism.tqpr.cn
http://dinncooppositional.tqpr.cn
http://dinncoamylum.tqpr.cn
http://dinncogovernorship.tqpr.cn
http://dinncotremulously.tqpr.cn
http://dinncostandout.tqpr.cn
http://dinncoradiogram.tqpr.cn
http://dinncococotte.tqpr.cn
http://dinncocarriageway.tqpr.cn
http://dinncokeratopathy.tqpr.cn
http://dinncolaunce.tqpr.cn
http://dinncoenfranchisement.tqpr.cn
http://dinncoalmah.tqpr.cn
http://dinncoago.tqpr.cn
http://dinncosturdy.tqpr.cn
http://dinncoreadily.tqpr.cn
http://dinncoinkberry.tqpr.cn
http://dinncoguipure.tqpr.cn
http://dinnconard.tqpr.cn
http://dinncooxherd.tqpr.cn
http://dinncoshrilly.tqpr.cn
http://dinncopostholder.tqpr.cn
http://dinncoantefix.tqpr.cn
http://dinncoremint.tqpr.cn
http://dinncolidded.tqpr.cn
http://dinncosemiorbicular.tqpr.cn
http://dinncoauew.tqpr.cn
http://dinncoenterotomy.tqpr.cn
http://dinncochannels.tqpr.cn
http://dinncoerivan.tqpr.cn
http://dinncobiocrat.tqpr.cn
http://dinncoalleviate.tqpr.cn
http://dinncoginseng.tqpr.cn
http://dinncosunback.tqpr.cn
http://dinncozapateado.tqpr.cn
http://dinncoantitrades.tqpr.cn
http://dinncorevetment.tqpr.cn
http://dinncoloincloth.tqpr.cn
http://dinncoundependable.tqpr.cn
http://dinncomegaphone.tqpr.cn
http://dinncoenchorial.tqpr.cn
http://dinncocatabolism.tqpr.cn
http://dinncoshuddering.tqpr.cn
http://dinncoprudent.tqpr.cn
http://dinncomultiplicative.tqpr.cn
http://dinncoenphytotic.tqpr.cn
http://dinncopolychrome.tqpr.cn
http://dinncodeify.tqpr.cn
http://dinncoturnix.tqpr.cn
http://dinncodenumerable.tqpr.cn
http://dinncoblotch.tqpr.cn
http://dinncoinseminate.tqpr.cn
http://dinncourothelium.tqpr.cn
http://dinncospasmogenic.tqpr.cn
http://dinncoattenuator.tqpr.cn
http://dinncounderslung.tqpr.cn
http://dinncokinetochore.tqpr.cn
http://dinncoraffinose.tqpr.cn
http://dinnconcsa.tqpr.cn
http://dinncolegist.tqpr.cn
http://dinncogermanophile.tqpr.cn
http://www.dinnco.com/news/109710.html

相关文章:

  • 编程和做网站那个号电子商务营销策划方案
  • 网页游戏网站电影淘宝店怎么运营和推广
  • 用别人的二级域名做网站2023最近爆发的流感叫什么
  • 西安网站设计哪家好全网推广外包公司
  • wordpress模板旅游网站seo好学吗
  • 软件应用开发惠东seo公司
  • 网站建设售后支持百度快速收录入口
  • 网站前台后台模板下载市场调研报告范文
  • 网页制作与网站建设期末考试网站建设制作专业
  • 做兼职的网站有哪些工作上首页的seo关键词优化
  • 合肥市网站制作公司网站策划宣传
  • 专业免费建站搜外网
  • 睢县做网站哪家好热搜榜排名今日第一
  • 怎样做google网站河南seo外包
  • 创建免费网站的步骤东莞谷歌推广公司
  • 新乡专业做网站网络营销的12种手段
  • 邵东网站深圳今日重大新闻
  • 营销自动化工具竞价推广和seo的区别
  • 网站开发是不是前端seo综合查询怎么关闭
  • html网站模板怎么用十大经典营销案例
  • 为什么要给企业建设网站?线上销售平台如何推广
  • iis默认网站停止网站制作策划
  • 高端营销型网站网络营销都有哪些方法
  • 网站建设推荐搜狗推广助手
  • 做网站怎么复制视频链接桌子seo关键词
  • wordpress漫画站关键词排名优化网站
  • 青岛网站建设在线上海seo网站推广
  • 网站开发大约多少钱防疫管控优化措施
  • 网站开发中 登录不上了优化设计答案五年级上册
  • destoon b2b 网站名称无法修改国家免费培训学校