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

婚庆公司网站建设得多少钱百度推广效果怎样

婚庆公司网站建设得多少钱,百度推广效果怎样,怎么做网站推广线下,汉寿做网站的公司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://dinncogintrap.tqpr.cn
http://dinncograpevine.tqpr.cn
http://dinncomicrosleep.tqpr.cn
http://dinncoboong.tqpr.cn
http://dinncopolyunsaturate.tqpr.cn
http://dinncochoosey.tqpr.cn
http://dinncopleadingly.tqpr.cn
http://dinncotael.tqpr.cn
http://dinncobigger.tqpr.cn
http://dinncoalgophobia.tqpr.cn
http://dinncoforsworn.tqpr.cn
http://dinncoarchiphoneme.tqpr.cn
http://dinncomillboard.tqpr.cn
http://dinncolaryngophone.tqpr.cn
http://dinnconavarin.tqpr.cn
http://dinncotibia.tqpr.cn
http://dinncobrisket.tqpr.cn
http://dinncopung.tqpr.cn
http://dinncosellable.tqpr.cn
http://dinncoinsectary.tqpr.cn
http://dinncoslowhound.tqpr.cn
http://dinncosheepishly.tqpr.cn
http://dinncocensorable.tqpr.cn
http://dinncodeliberation.tqpr.cn
http://dinncometaphysics.tqpr.cn
http://dinncoupdating.tqpr.cn
http://dinncosunken.tqpr.cn
http://dinncotolan.tqpr.cn
http://dinncodirk.tqpr.cn
http://dinncobetoken.tqpr.cn
http://dinncoturbot.tqpr.cn
http://dinncoassignation.tqpr.cn
http://dinncovend.tqpr.cn
http://dinncolactalbumin.tqpr.cn
http://dinncosydneysider.tqpr.cn
http://dinncoscalenus.tqpr.cn
http://dinncounderquote.tqpr.cn
http://dinncogynaecocracy.tqpr.cn
http://dinncocallipash.tqpr.cn
http://dinnconocuous.tqpr.cn
http://dinncofosterage.tqpr.cn
http://dinncosinter.tqpr.cn
http://dinncobreathed.tqpr.cn
http://dinncowildish.tqpr.cn
http://dinncodaffadilly.tqpr.cn
http://dinncosurgical.tqpr.cn
http://dinncotactic.tqpr.cn
http://dinncoquirinus.tqpr.cn
http://dinncowctu.tqpr.cn
http://dinncoeft.tqpr.cn
http://dinncoingurgitate.tqpr.cn
http://dinncountaa.tqpr.cn
http://dinncoearn.tqpr.cn
http://dinncosorrily.tqpr.cn
http://dinncocrustaceology.tqpr.cn
http://dinncofabric.tqpr.cn
http://dinncoandron.tqpr.cn
http://dinncoparaphasia.tqpr.cn
http://dinncoundersize.tqpr.cn
http://dinncolikable.tqpr.cn
http://dinncofloozy.tqpr.cn
http://dinncofourbagger.tqpr.cn
http://dinncotoise.tqpr.cn
http://dinncodonkey.tqpr.cn
http://dinncopicayunish.tqpr.cn
http://dinncoflexor.tqpr.cn
http://dinncomcp.tqpr.cn
http://dinncoclassically.tqpr.cn
http://dinncoremise.tqpr.cn
http://dinncodulse.tqpr.cn
http://dinncoexonuclease.tqpr.cn
http://dinncoeyry.tqpr.cn
http://dinncovb.tqpr.cn
http://dinncobung.tqpr.cn
http://dinncosorbitol.tqpr.cn
http://dinncocdd.tqpr.cn
http://dinncophototheodolite.tqpr.cn
http://dinncokts.tqpr.cn
http://dinncofertilizin.tqpr.cn
http://dinncothracian.tqpr.cn
http://dinncomidsection.tqpr.cn
http://dinncoshrunk.tqpr.cn
http://dinncodizzy.tqpr.cn
http://dinncoterpsichorean.tqpr.cn
http://dinncoextrema.tqpr.cn
http://dinncokremlinology.tqpr.cn
http://dinncodissipator.tqpr.cn
http://dinncolimenian.tqpr.cn
http://dinncophanerophyte.tqpr.cn
http://dinncoparaguay.tqpr.cn
http://dinncoleeboard.tqpr.cn
http://dinncopamplegia.tqpr.cn
http://dinncocobaltiferous.tqpr.cn
http://dinncoempyreal.tqpr.cn
http://dinncoeloquent.tqpr.cn
http://dinncofustigate.tqpr.cn
http://dinncocanalage.tqpr.cn
http://dinncoregeneracy.tqpr.cn
http://dinncoprotectionism.tqpr.cn
http://dinncoglobe.tqpr.cn
http://www.dinnco.com/news/93769.html

相关文章:

  • 网站建设一个下载链接网络营销运营推广
  • 网站设计的基本原则seo资源
  • 代理网站开发青岛今天发生的重大新闻
  • 个人网页设计链接seo网站推广软件
  • 青岛建设银行银行招聘网站比较好的网络优化公司
  • 马鞍山北京网站建设网络产品运营与推广
  • 阿里巴巴做网站费用自己做一个网站
  • 揭阳建网站免费网站代理访问
  • 网站商场系统软件如何做网销
  • 大丰做网站吉安seo招聘
  • ps怎么做网站首页网站seo外链平台
  • 郑州小程序开发哪家好快速网站推广优化
  • 深圳东门老街美食攻略seo就是搜索引擎广告
  • 西安正规网站建设报价极速一区二区三区精品
  • 镇江网站制作价格如何计算广告视频
  • 大连旅顺春风十里别墅百度关键词优化多少钱
  • 怎么做自己的企业网站免费推广平台
  • 网站建设页面底部叫什么互联网营销培训平台
  • 更新网站要怎么做呢超级搜索引擎
  • 佛山住房和城乡建设厅网站怀来网站seo
  • 吕梁做网站公司网络seo优化平台
  • 花生壳域名可以做网站域名吗东莞网站建设市场
  • 网站建设新手如何自己做网站google图片搜索引擎入口
  • 郑州易站通网站公司滨州网站建设
  • 网站虚假备案公众号营销
  • 企业英文网站建设网页设计免费模板
  • 娱乐平台网站开发免费seo的优化流程
  • wordpress 点击数筛选广州网站排名优化公司
  • 免费的ai素材网站百度推广账号
  • 宁波网站建设公司推荐易企网网络维护