玫瑰花Java web程序

2024-05-12 14:32
文章标签 java 程序 web 玫瑰花

本文主要是介绍玫瑰花Java web程序,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

玫瑰花Java web程序

  有兴趣的同学可以参考一下

Java类RoseController

package com.spring.controller;import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;import javax.print.attribute.HashAttributeSet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;import net.sf.json.JSONObject;import org.apache.commons.collections.map.HashedMap;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;@Controller
public class RoseController {//鐢ㄤ簬璺宠浆椤甸潰@RequestMapping(value="skip/page",method = {RequestMethod.GET,RequestMethod.POST})public ModelAndView skipRose(HttpServletRequest request,HttpServletResponse response){ModelAndView mav=new ModelAndView();System.out.println("come in system");mav.addObject("wishing", "YOU ARE WELCOME!");mav.setViewName("rose/roseindex");return mav;}///灏嗘暟鎹繚瀛樺埌鏂囨湰涓�@RequestMapping(value="save/keepdata",method = {RequestMethod.GET,RequestMethod.POST})public ModelAndView keepdata(HttpServletRequest request,HttpServletResponse response) throws IOException{request.setCharacterEncoding("UTF-8");//response.setContentType("text/html,charset=UTF-8");response.setCharacterEncoding("utf-8");PrintWriter out=response.getWriter();ModelAndView mav=new ModelAndView();String keyword=request.getParameter("pwd");File file=new File("D:\\xuan22.txt");if(!file.exists()){file.createNewFile();}/*PrintStream p = new PrintStream(new BufferedOutputStream(new FileOutputStream(aFile, true)));杩欓噷鐨則rue璇存槑鏄拷鍔�濡傛灉false璇存槑瑕嗙洊*/FileOutputStream fos=new FileOutputStream(file,true);///保存文件续写OutputStreamWriter osw=new OutputStreamWriter(fos);BufferedWriter bufw=new BufferedWriter(osw);//绠�啓//BufferedWriter bufw2=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)));Date date=new Date();SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd:HH:mm:ss");String time=sdf.format(date);System.out.println("====="+keyword);///鑾峰彇IPString ip="";if (request.getHeader("x-forwarded-for") == null) {  ip=request.getRemoteAddr();//System.out.println("======ip1======="+ip);}else{ip=request.getHeader("x-forwarded-for");//System.out.println("======ip2======="+ip);}//System.out.println("淇濆瓨鏂囦欢");bufw.write(keyword+"======"+ip+"======"+time);bufw.newLine();//bufw.flush();bufw.close();//Map<String,Object> map=new HashedMap();int count=0;HttpSession session=request.getSession();if(request.getParameter("count")!=null){//System.out.println("====3====="+count);count=Integer.parseInt(request.getParameter("count"));}JSONObject json=new JSONObject();if(count<3){count++;json.put("count", String.valueOf(count));json.put("text", "密码不正确。请重新输入!0_0");out.print(json.toString());}else if(count>=3 && count<=6){//System.out.println("===1==="+count);count++;json.put("count", String.valueOf(count));json.put("text", "你怎么那么笨,这么简单的密码都猜不到0_0");out.print(json.toString());}else if(count>=6 && count<=12){//System.out.println("====2=="+count);count++;json.put("count", String.valueOf(count));json.put("text", "惊喜就在这一刻");out.print(json.toString());}else if(count>=12){//System.out.println("====3=="+count);count=0;json.put("count", String.valueOf(count));json.put("text", "想看到惊喜的,请继续输入密码吧");out.print(json.toString());}if(keyword.equals("lovelili201314")){mav.setViewName("rose/roseopen");json.put("text", "密码正确");return mav;}else{mav.addObject("data", "请重新输入!");return null;}}//鐢ㄤ簬璺宠浆椤甸潰@RequestMapping(value="/rose/redirect")public ModelAndView redirectRose(HttpServletRequest request,HttpServletResponse response){ModelAndView mav=new ModelAndView();mav.addObject("wishing", "YOU ARE WELCOME!");mav.setViewName("rose/roseopen");return mav;}}

jsp页面:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><base href="<%=basePath%>"><title>Rose Love from this moment</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0">    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><link rel="shortcut icon" href="<%=path%>/images/ico/15.png" type="image/x-icon" /><!--<link rel="stylesheet" type="text/css" href="styles.css">--><script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script><script type="text/javascript" src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script><style type="text/css">
.inputKey{float:right;margin-right:10px;margin-top:10px;border:2px solid #009;
}.inputKey .input{float:left;height:26px;line-height:26px;font-size:14px;border:0px solid #F60;
}
.inputKey .button{float:left;width:60px;height:26px;line-height:20px;text-align:center; background:#009;color:#fff;font-size:14px;border:0;
}.inputKey .button:hover{float:left;width:60px;height:26px;line-height:20px;text-align:center; background:#001;color:#fff;font-size:14px;border:0;
}#content{width:300px;height:60px;margin:auto;/* margin-top:400px; */
}#imgico{width:300px;height:300px;margin:auto;margin-top:100px;
}
#imgico .img1 {float:left;width:120px;height:300px;/* background-attachment: fixed; */background-image: url(<%=path%>/images/roseimg/14.png);background-repeat: no-repeat;background-position: 0 160;
}
#imgico .img2 {float:right;width:150px;height:300px;/* background-attachment: fixed; */background-image: url(<%=path%>/images/roseimg/2.png);background-repeat: no-repeat;background-position: 0 90;
}
.cuetext{float:left;border:0px solid #F60;margin-top:270px;color:red;font-size:20px;
}
#prompt{width:300px;height:40px;margin:auto;margin-top:0px;
}
#prompttext{height:40px;margin:auto;margin-top:0px;text-align:center;
}</style></head><body><div id="imgico"><div class="img1"></div><div class="img2"><p class="cuetext">亲,请输入密码!</p></div></div><div id="content"> <div class="inputKey"><form action="#" method="post" name="form1"><input type="password" name="keyword" id="keyword" class="input" size="30px"/><input type="button" id="bt1" value="惊喜" class="button" /></form></div></div><div id="prompt"><input type="hidden" id="count" name="count" value="0"/><p id="prompttext" style="color:red"></p></div></body>
</html><script type="text/javascript">
<!--$("#bt1").click(function(){var va=$("#keyword").val();if(va==""){$("#prompttext").text("密码不能为空,请输入!");}else{$.post("save/keepdata",{pwd:$("#keyword").val(),count:$("#count").val()},function(data,textStatus){var jsonObj=eval("("+data+")");$("#count").val(jsonObj.count);$("#prompttext").text(jsonObj.text);});}});$("#keyword").focus(function(){$("#prompttext").text("");$("#keyword").val("");});//-->
</script>

效果图:


弹出玫瑰花效果:



这篇关于玫瑰花Java web程序的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/982880

相关文章

springboot集成easypoi导出word换行处理过程

《springboot集成easypoi导出word换行处理过程》SpringBoot集成Easypoi导出Word时,换行符n失效显示为空格,解决方法包括生成段落或替换模板中n为回车,同时需确... 目录项目场景问题描述解决方案第一种:生成段落的方式第二种:替换模板的情况,换行符替换成回车总结项目场景s

SpringBoot集成redisson实现延时队列教程

《SpringBoot集成redisson实现延时队列教程》文章介绍了使用Redisson实现延迟队列的完整步骤,包括依赖导入、Redis配置、工具类封装、业务枚举定义、执行器实现、Bean创建、消费... 目录1、先给项目导入Redisson依赖2、配置redis3、创建 RedissonConfig 配

SpringBoot中@Value注入静态变量方式

《SpringBoot中@Value注入静态变量方式》SpringBoot中静态变量无法直接用@Value注入,需通过setter方法,@Value(${})从属性文件获取值,@Value(#{})用... 目录项目场景解决方案注解说明1、@Value("${}")使用示例2、@Value("#{}"php

SpringBoot分段处理List集合多线程批量插入数据方式

《SpringBoot分段处理List集合多线程批量插入数据方式》文章介绍如何处理大数据量List批量插入数据库的优化方案:通过拆分List并分配独立线程处理,结合Spring线程池与异步方法提升效率... 目录项目场景解决方案1.实体类2.Mapper3.spring容器注入线程池bejsan对象4.创建

线上Java OOM问题定位与解决方案超详细解析

《线上JavaOOM问题定位与解决方案超详细解析》OOM是JVM抛出的错误,表示内存分配失败,:本文主要介绍线上JavaOOM问题定位与解决方案的相关资料,文中通过代码介绍的非常详细,需要的朋... 目录一、OOM问题核心认知1.1 OOM定义与技术定位1.2 OOM常见类型及技术特征二、OOM问题定位工具

基于 Cursor 开发 Spring Boot 项目详细攻略

《基于Cursor开发SpringBoot项目详细攻略》Cursor是集成GPT4、Claude3.5等LLM的VSCode类AI编程工具,支持SpringBoot项目开发全流程,涵盖环境配... 目录cursor是什么?基于 Cursor 开发 Spring Boot 项目完整指南1. 环境准备2. 创建

Spring Security简介、使用与最佳实践

《SpringSecurity简介、使用与最佳实践》SpringSecurity是一个能够为基于Spring的企业应用系统提供声明式的安全访问控制解决方案的安全框架,本文给大家介绍SpringSec... 目录一、如何理解 Spring Security?—— 核心思想二、如何在 Java 项目中使用?——

SpringBoot+RustFS 实现文件切片极速上传的实例代码

《SpringBoot+RustFS实现文件切片极速上传的实例代码》本文介绍利用SpringBoot和RustFS构建高性能文件切片上传系统,实现大文件秒传、断点续传和分片上传等功能,具有一定的参考... 目录一、为什么选择 RustFS + SpringBoot?二、环境准备与部署2.1 安装 RustF

springboot中使用okhttp3的小结

《springboot中使用okhttp3的小结》OkHttp3是一个JavaHTTP客户端,可以处理各种请求类型,比如GET、POST、PUT等,并且支持高效的HTTP连接池、请求和响应缓存、以及异... 在 Spring Boot 项目中使用 OkHttp3 进行 HTTP 请求是一个高效且流行的方式。

java.sql.SQLTransientConnectionException连接超时异常原因及解决方案

《java.sql.SQLTransientConnectionException连接超时异常原因及解决方案》:本文主要介绍java.sql.SQLTransientConnectionExcep... 目录一、引言二、异常信息分析三、可能的原因3.1 连接池配置不合理3.2 数据库负载过高3.3 连接泄漏