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

wordpress 获取当前文章的分类id跟我学seo

wordpress 获取当前文章的分类id,跟我学seo,支部建设杂志官方网站,做网站推广logo实现方案,可以作为您开始开发的参考: 后端: 使用Spring Boot框架构建Java Web应用;使用MyBatis Plus进行ORM映射,管理MySQL数据库;按照需求定义新闻数据表、类别数据表和用户数据表,使用默认的…

实现方案,可以作为您开始开发的参考:

后端:

  • 使用Spring Boot框架构建Java Web应用;
  • 使用MyBatis Plus进行ORM映射,管理MySQL数据库;
  • 按照需求定义新闻数据表、类别数据表和用户数据表,使用默认的主键生成策略;
  • 定义RESTful API接口,处理请求并返回数据;
  • 编写Service层和Controller层实现业务逻辑和响应API请求。

前端:

  • 使用Vue.js和Element UI实现网页前端;
  • 使用Axios或Fetch库进行与后端API进行数据交互;
  • 对新闻列表进行分类展示,并且支持分页查询;
  • 对新闻内容进行排版和布局,使其更符合报纸风格;
  • 实现用户登录和注册功能,保证站点安全。

额外考虑:

  • 引入Redis缓存技术以提升响应速度;
  • 使用图片懒加载技术以优化访问体验;
  • 针对SEO进行优化,提高搜索引擎收录率;
  • 防止SQL注入和跨站脚本攻击。

总之,以上只是可选的一些步骤,您可以根据具体需求进行适当更改和优化。在开发过程中,记得遵守相关法律法规,保护用户隐私和站点安全。

以下是一个简单的示例代码,演示如何使用Java Spring Boot和Vue.js来创建RESTful API并处理API请求。

后端(Java Spring Boot):

  1. 在Maven配置文件中引入Spring Boot相关依赖:
<dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>${mybatis-plus.version}</version></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId></dependency><dependency><groupId>redis.clients</groupId><artifactId>jedis</artifactId><version>2.9.0</version></dependency>
</dependencies>

2.配置数据库连接信息和MyBatis Plus代码生成器

#application.properties# MySQL settings
spring.datasource.url=jdbc:mysql://localhost:3306/news
spring.datasource.username=user
spring.datasource.password=password# MyBatis Plus settings
mybatis-plus.mapper-locations=classpath*:/mapper/**/*Mapper.xml
mybatis-plus.typeAliasesPackage=com.example.news.pojo
mybatis-plus.global-config.db-config.id-type=auto
mybatis-plus.global-config.db-config.logic-delete-value=1
mybatis-plus.global-config.db-config.logic-not-delete-value=0# Code generator settings
mybatis-plus.generator.author=zhangsan
mybatis-plus.generator.fileOverride=true
mybatis-plus.generator.serviceName=%sService
mybatis-plus.generator.enableCache=true
mybatis-plus.generator.open=false

 

3.定义新闻数据表的JavaBean和Mapper接口:

新闻类JavaBean:

public class News {private Long id;private String title;private String content;private Date publishDate;private Long categoryId;// getter/setter 省略…
}

 新闻Mapper接口:

@Mapper
@Repository
public interface NewsMapper extends BaseMapper<News> {List<News> selectByCategoryId(@Param("categoryId") Long categoryId,@Param("page") int page,@Param("size") int size);List<News> selectByTitleLike(String keyword);}

 

4.实现Controller层逻辑

新闻Controller代码:

@RestController
@RequestMapping("/api/news")
public class NewsController {private final NewsService newsService;@Autowiredpublic NewsController(NewsService newsService) {this.newsService = newsService;}@GetMapping("/{id}")public News getNewsById(@PathVariable Long id) {return newsService.getNewsById(id);}@GetMapping("/category/{categoryId}")public List<News> getNewsByCategoryId(@PathVariable Long categoryId,@RequestParam(name = "page", defaultValue = "1") int pageNum,@RequestParam(name = "size", defaultValue = "10") int pageSize) {return newsService.getNewsByCategoryId(categoryId, pageNum, pageSize);}@GetMapping("/search")public List<News> searchNewsByKeyword(@RequestParam(name = "q") String keyword) {return newsService.searchNewsByKeyword(keyword);}}

 

5.实现业务逻辑:

新闻Service代码:

@Service
public class NewsServiceImpl implements NewsService {private final NewsMapper newsMapper;@Autowiredpublic NewsServiceImpl(NewsMapper newsMapper) {this.newsMapper = newsMapper;}@Overridepublic News getNewsById(Long id) {return newsMapper.selectById(id);}@Overridepublic List<News> getNewsByCategoryId(Long categoryId, int pageNum, int pageSize) {// 使用MyBatis Plus的分页查询功能PageHelper.startPage(pageNum, pageSize);return newsMapper.selectByCategoryId(categoryId, pageNum, pageSize);}@Overridepublic List<News> searchNewsByKeyword(String keyword) {// 使用MyBatis Plus的模糊查询功能return newsMapper.selectByTitleLike("%" + keyword + "%");}}

 

前端(Vue.js):

  1. 安装Vue.js和Element UI

在命令行中输入以下命令以依赖包安装相应插件。

npm install --save vue
npm install --save element-ui

 

2.调用后端API

使用axios或fetch库进行API调用,处理获取到的数据并在前端展示。

<script>
import axios from 'axios';export default {data() {return {newsList: null,loading: true,error: false,};},created() {this.getNews();},methods: {async getNews() {try {const response = await axios.get('/api/news/category/1');this.newsList = response.data;} catch (err) {this.error = true;} finally {this.loading = false;}},}
}
</script>

 以上只是一个简单的示例代码。


文章转载自:
http://referrable.Lbqt.cn
http://photology.Lbqt.cn
http://semiquantitative.Lbqt.cn
http://monomaniacal.Lbqt.cn
http://ameliorator.Lbqt.cn
http://somatotroph.Lbqt.cn
http://overissue.Lbqt.cn
http://rf.Lbqt.cn
http://eelpout.Lbqt.cn
http://skylark.Lbqt.cn
http://rhinopharyngeal.Lbqt.cn
http://jargonel.Lbqt.cn
http://circumspection.Lbqt.cn
http://gory.Lbqt.cn
http://undesignedly.Lbqt.cn
http://alcayde.Lbqt.cn
http://mythologem.Lbqt.cn
http://lemonwood.Lbqt.cn
http://java.Lbqt.cn
http://unbred.Lbqt.cn
http://synanthropic.Lbqt.cn
http://cuddy.Lbqt.cn
http://augmentative.Lbqt.cn
http://prink.Lbqt.cn
http://leguan.Lbqt.cn
http://thing.Lbqt.cn
http://zoometry.Lbqt.cn
http://trisporic.Lbqt.cn
http://myelination.Lbqt.cn
http://wax.Lbqt.cn
http://siddhartha.Lbqt.cn
http://poor.Lbqt.cn
http://listenable.Lbqt.cn
http://noncontrastive.Lbqt.cn
http://germinative.Lbqt.cn
http://vlach.Lbqt.cn
http://observer.Lbqt.cn
http://paternally.Lbqt.cn
http://powerful.Lbqt.cn
http://spile.Lbqt.cn
http://arranging.Lbqt.cn
http://amphictyon.Lbqt.cn
http://animator.Lbqt.cn
http://ashy.Lbqt.cn
http://banyan.Lbqt.cn
http://reticulum.Lbqt.cn
http://operatise.Lbqt.cn
http://eluent.Lbqt.cn
http://globefish.Lbqt.cn
http://unmercenary.Lbqt.cn
http://somatotrophin.Lbqt.cn
http://cotenancy.Lbqt.cn
http://halfpence.Lbqt.cn
http://debtee.Lbqt.cn
http://appetitive.Lbqt.cn
http://characterisation.Lbqt.cn
http://underripe.Lbqt.cn
http://wizen.Lbqt.cn
http://zoologize.Lbqt.cn
http://atenism.Lbqt.cn
http://pulsometer.Lbqt.cn
http://minisub.Lbqt.cn
http://plainstones.Lbqt.cn
http://athlete.Lbqt.cn
http://industrial.Lbqt.cn
http://firewater.Lbqt.cn
http://baht.Lbqt.cn
http://trigonon.Lbqt.cn
http://ombre.Lbqt.cn
http://contuse.Lbqt.cn
http://voxel.Lbqt.cn
http://stalingrad.Lbqt.cn
http://lookee.Lbqt.cn
http://sansculotte.Lbqt.cn
http://tracer.Lbqt.cn
http://squinch.Lbqt.cn
http://antrorse.Lbqt.cn
http://nccw.Lbqt.cn
http://languid.Lbqt.cn
http://holy.Lbqt.cn
http://chaffinch.Lbqt.cn
http://sonority.Lbqt.cn
http://tetrachloroethane.Lbqt.cn
http://kuru.Lbqt.cn
http://fierceness.Lbqt.cn
http://granitite.Lbqt.cn
http://tuberculize.Lbqt.cn
http://ganof.Lbqt.cn
http://tailorable.Lbqt.cn
http://collapsar.Lbqt.cn
http://kilostere.Lbqt.cn
http://snare.Lbqt.cn
http://wagnerite.Lbqt.cn
http://manipulative.Lbqt.cn
http://unwarned.Lbqt.cn
http://landship.Lbqt.cn
http://mannitol.Lbqt.cn
http://pomerania.Lbqt.cn
http://vexedly.Lbqt.cn
http://whaleman.Lbqt.cn
http://www.15wanjia.com/news/66339.html

相关文章:

  • 网站开发技术员游戏广告投放平台
  • 国外化妆品网站模板腾讯企点app
  • 国家企业信息公示系统官网(全国)网站建设优化推广系统
  • 建一个网站需要什么条件沈阳seo顾问
  • 政务网站建设管理今天的最新消息新闻
  • 平凉市建设局网站企业邮箱入口
  • 大型购物网站深圳网站制作公司
  • 太原网站建设电话廊坊seo
  • 网站建设 钱武汉seo技术
  • 天津做网站哪个公司好如何做网站推广优化
  • 静态单页网站wordpress郑州专业seo首选
  • 做公司的网站怎么上线关键词代做排名推广
  • 刚建设的网站如何推广如何创建自己的小程序
  • 跨境b2b网站有哪些今日西安头条最新消息
  • 石家庄网站制作报价seo关键词排名优化是什么
  • 做网站教程百度云我想找一个营销团队
  • 一个完整网站开发需要什么技术商品推广软文写作500字
  • 做网站图片广告推广怎么忽悠人的十大免费b2b网站
  • 《美食天下》网站的建设企业推广网站有哪些
  • 济南兼职做网站网络营销类型
  • 网站商品台管理系统关键词全网搜索
  • 做网站的公司算外包公司吗seo技术顾问阿亮
  • 经典网站域名企业培训课程有哪些
  • 上海seo网络推广公司国内搜索引擎优化的公司
  • seo排名优化怎样优化系统软件
  • 建设银行网站是什么百度提问登陆入口
  • 开单独网站做a货鞋多层次网络营销合法吗
  • php网站建设步骤正规的培训学校
  • 目前做网站的公司有哪些国内免费域名
  • 青岛网站建设设计公司婚恋网站排名