nginx转发get请求丢失参数

场景:

用nginx转发请求时,需要剥离某些字段。

如:

http://127.0.0.1/myname/api/baseinfo/getlist?class=1

需要将请求设置为:

http://127.0.0.1:8080/api/baseinfo/getlist?class=1

一开始的location配置为:

location ~ /myname/(.*) {
    proxy_pass $scheme://127.0.0.1:8080/$1;
}

但是发现 ? 后面的请求参数没有被转发,修改后的location配置如下:

location ~ /myname/(.*)$ {
    proxy_pass $scheme://127.0.0.1:8080/$1?$args;
}

问题解决!

 

参考文章:

nginx正则捕获get请求参数丢失的解决

 

好的,以下是一个可以从文件中读取单词的背单词程序的实现思路: 1. 创建一个JFrame窗口,用于显示单词和生词本。 2. 在窗口中添加一个JLabel标签,用于显示单词。 3. 在窗口中添加一个JButton按钮,用于控制单词显示速度。 4. 在窗口中添加一个JButton按钮,用于标记生词并加入生词本。 5. 创建一个单词列表,用于保存需要背诵的单词。 6. 创建一个生词本列表,用于保存标记的生词。 7. 创建一个计时器,用于控制单词的显示速度。 8. 在计时器的回调函数中,依次显示单词列表中的每个单词。 9. 在标记生词的按钮回调函数中,将当前显示的单词加入生词本列表中。 10. 读取单词文件,将单词添加到单词列表中。 以下是代码示例: ```java import java.awt.event.*; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import javax.swing.*; public class WordLearning extends JFrame implements ActionListener { private JLabel wordLabel; private JButton speedButton; private JButton addWordButton; private Timer timer; private DefaultListModel<String> wordListModel; private DefaultListModel<String> newWordListModel; public WordLearning() { // 初始化窗口 setTitle("Word Learning"); setSize(300, 200); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // 初始化单词标签和按钮 wordLabel = new JLabel(); add(wordLabel); speedButton = new JButton("Speed"); add(speedButton); addWordButton = new JButton("Add Word"); add(addWordButton); // 初始化单词列表和生词本列表 wordListModel = new DefaultListModel<String>(); newWordListModel = new DefaultListModel<String>(); loadWordsFromFile("words.txt"); // 初始化计时器 timer = new Timer(2000, this); timer.start(); // 绑定按钮事件 speedButton.addActionListener(this); addWordButton.addActionListener(this); // 显示窗口 setVisible(true); } public void actionPerformed(ActionEvent e) { if (e.getSource() == timer) { // 显示下一个单词 if (wordListModel.size() > 0) { String word = wordListModel.firstElement(); wordListModel.removeElementAt(0); wordLabel.setText(word); } else { // 如果单词列表已经为空,则停止计时器 timer.stop(); } } else if (e.getSource() == speedButton) { // 改变单词显示速度 timer.setDelay(timer.getDelay() / 2); } else if (e.getSource() == addWordButton) { // 标记生词并加入生词本 String newWord = wordLabel.getText(); newWordListModel.addElement(newWord); } } private void loadWordsFromFile(String filename) { try { BufferedReader reader = new BufferedReader(new FileReader(filename)); String line = null; while ((line = reader.readLine()) != null) { wordListModel.addElement(line.trim()); } reader.close(); } catch (IOException e) { System.out.println("Failed to load words from file: " + filename); } } public static void main(String[] args) { new WordLearning(); } } ``` 注意:以上代码仅为示例,实现效果可能不够完善,仅供参考。在实际开发中,需要根据具体需求进行调整和完善。同时需要注意的是,单词文件的格式需要按照每行一个单词的方式进行保存,并且需要保证文件存在并且可读。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值