java文章后台提取代码 java公共代码块提取

JSP取后台JAVA代码

应该是用struts作的吧,a.java是一个action类,在action类中将获得值保存到request或session中,也就是request.setAttribute("xxx",xxxx);在c.jsp中获得request或session中的值,%=request.getAttribute(xxx);% 这样就把后面的xxxx的值获得了。

十余年的天元网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。全网整合营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整天元建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。成都创新互联公司从事“天元网站设计”,“天元网站推广”以来,每个客户项目都认真落实执行。

求一个提取文章关键词的java程序

//直接粘贴就行。

import java.awt.BorderLayout;

import java.awt.EventQueue;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.io.File;

import java.io.IOException;

import java.io.PrintWriter;

import java.util.ArrayList;

import java.util.Scanner;

import javax.swing.BorderFactory;

import javax.swing.JButton;

import javax.swing.JFileChooser;

import javax.swing.JFrame;

import javax.swing.JPanel;

import javax.swing.JSplitPane;

import javax.swing.JTextArea;

import javax.swing.border.EtchedBorder;

import javax.swing.filechooser.FileFilter;

public class Application2 extends JFrame implements Cloneable{

public Application2(){

this.setDefaultCloseOperation(EXIT_ON_CLOSE);

this.setSize(800,700);

this.setLayout(new BorderLayout());

keyWords1=new String[]{"那么","还是","sdf"};

keyWords2=new String[]{"所以","而且",};

input=new JTextArea();

JPanel ip=new JPanel();

ip.setLayout(new BorderLayout());

ip.add(input,BorderLayout.CENTER);

ip.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "输入文本"));

output1=new JTextArea();

JPanel o1p=new JPanel();

o1p.setLayout(new BorderLayout());

o1p.add(output1,BorderLayout.CENTER);

o1p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "以下为"));

output2=new JTextArea();

JPanel o2p=new JPanel();

o2p.setLayout(new BorderLayout());

o2p.add(output2,BorderLayout.CENTER);

o2p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "以下为"));

JSplitPane split1=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,o1p,o2p);

split1.setDividerLocation(350);

JSplitPane split2=new JSplitPane(JSplitPane.VERTICAL_SPLIT,ip,split1);

split2.setDividerLocation(300);

this.add(split2,BorderLayout.CENTER);

open=new JButton("导入");

open.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e){

JFileChooser chooser=new JFileChooser(".");

chooser.setMultiSelectionEnabled(false);

chooser.addChoosableFileFilter(new FileFilter(){

@Override

public boolean accept(File file) {

if(file.isDirectory())

return true;

int length=file.getName().length();

if(length5)

return false;

if(file.getName().substring(length-4).equals(".txt"))

return true;

return false;

}

@Override

public String getDescription() {

return "文本文件";

}

});

chooser.showOpenDialog(Application2.this);

File file=chooser.getSelectedFile();

if(file==null)

return;

try {

Scanner sc=new Scanner(file);

String text="";

while(sc.hasNextLine())

text+=sc.nextLine()+"\n";

input.setText(text);

String[] array=getSentences();

output1.setText(getKeySentences(keyWords1,array));

output2.setText(getKeySentences(keyWords2,array));

}catch (IOException e1) {

e1.printStackTrace();

}

}

});

save=new JButton("导出");

save.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e){

JFileChooser chooser=new JFileChooser(".");

chooser.setMultiSelectionEnabled(false);

chooser.addChoosableFileFilter(new FileFilter(){

@Override

public boolean accept(File file) {

if(file.isDirectory())

return true;

int length=file.getName().length();

if(length5)

return false;

if(file.getName().substring(length-4).equals(".txt"))

return true;

return false;

}

@Override

public String getDescription() {

return "文本文件";

}

});

chooser.showSaveDialog(Application2.this);

File file=chooser.getSelectedFile();

if(file==null)

return;

try {

PrintWriter pw=new PrintWriter(file);

pw.print(output1.getText());

pw.flush();

pw.print(output2.getText());

pw.flush();

}catch (IOException e1) {

e1.printStackTrace();

}

}

});

JPanel buttonPane=new JPanel();

buttonPane.add(open);

buttonPane.add(save);

this.add(buttonPane,BorderLayout.SOUTH);

}

public String[] getSentences(){

ArrayListString set=new ArrayListString();

int length=input.getText().length();

for(int i=0,last=0;ilength;i++){

String s=String.valueOf(input.getText().charAt(i));

if(s.equals("\n"))

last=i+1;

if(s.equals(".")||s.equals(",")||s.equals("。")||s.equals("。")||s.equals("!")||s.equals("?")||s.equals("?")||s.equals("!")||s.equals(",")){

set.add(input.getText().substring(last,i)+s);

last=i+1;

}

}

return set.StringtoArray(new String[set.size()]);

}

public String getKeySentences(String[] key,String[] sentences){

String result="";

A: for(int i=0;isentences.length;i++){

for (int k = 0; k key.length; k++)

if (sentences[i].contains(key[k].subSequence(0, key[k].length()))) {

result += sentences[i] + "\n";

continue A;

}

}

return result;

}

private JTextArea input;

private JTextArea output1;

private JTextArea output2;

private JButton open;

private JButton save;

private String[] keyWords1;

private String[] keyWords2;

public static void main(String... args){

EventQueue.invokeLater(new Runnable(){

public void run(){

new Application2().setVisible(true);

}

});

}

}

用java如何后台获得每一页网页的源代码

必须的,如果你跳过他的拦截器,直接访问它的页面,那就不安全了,在设计的时候就是这么设计的

Java 如何只提取网页源代码中的正文部分,就是正文部分包含标签也没关系,就是要那部分包含标签的正文

相似网页可以用正则表达式来截取

不同网站的设计,对正文部分没有一个统一的规则。。。

只能找规律,然后做一个类似通解的方法,但是误差无法避免了。。

大概思路如下:

可以尝试着做一个对比的方法,找出某个标签内的文字和标签的比例最大

文字最多,标签最少的 一般来说是正文

具体实现:

得到网页内容,把网页内容分析成一个树(按照每个标签为一个节点),树的内容包含子节点数和该树一下的文字内容数量。

大概的对节点进行对比分析,得到节点最少,文字最多的节点。 这个就是那个正文节点了。

以上内容只适合博客、文章、新闻类的网站。搜索引擎网站等 很多标签穿插其间的无法适用。

java web 纯html界面中如何获取后台session代码

给你提供两种方法:

el表达式:${sessionScope.key}

2.java代码:session.getAttribute(key)

分享名称:java文章后台提取代码 java公共代码块提取
地址分享:https://www.cdcxhl.com/article32/docopsc.html

成都网站建设公司_创新互联,为您提供动态网站电子商务搜索引擎优化品牌网站制作外贸网站建设

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

外贸网站制作