Apache关闭虚拟机目录浏览功能

1、首先在Apache的配置文件夹里面找到extra这个文件,找到httpd-vhosts.conf文件(为了修改之后能找回备份,这也是推荐的一一种方式),打开这个文件,找到你需要修改的虚拟主机配置行,找到如下配置

<Directory "virtualPathName">
        #defaule document
        Options Indexes FollowSymLinks
        AllowOverride None
        #权限控制
        Require all granted
    </Directory>

将Options Indexes FollowSymLinks

改为

Options FollowSymLinks

确定修改,重启Apache,这样你的当前虚拟机就关闭了文件目录访问功能,这里还有一点,就是我们修改之后就没有了默认访问指定文件的功能(如果你的Apache没有配置默认访问文件的情况下),下面写配置;

在你的虚拟机配置下直接添加如下配置

<IfModule dir_module> 

        #这里你也可以将index.php 、index.html修改为其他文件;
        DirectoryIndex  index.php index.html

</IfModule>

这样你打开一个文件夹当没有默认文件下就不能浏览目录,并且请求会被拒绝,配置了默认文件,则访问默认文件;

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要实现 Android Apache POI 文件浏览功能,可以按照以下步骤进行: 1. 在项目的 build.gradle 文件中添加 Apache POI 的依赖项: ``` implementation 'org.apache.poi:poi:4.1.2' implementation 'org.apache.poi:poi-ooxml:4.1.2' ``` 2. 在布局文件中添加一个用于显示文件内容的 TextView: ``` <TextView android:id="@+id/tv_file_content" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="16sp" android:padding="16dp" /> ``` 3. 在 Activity 中获取传递过来的文件路径,并使用 Apache POI 读取文件内容: ``` private void readExcelFile(String filePath) { try { InputStream inputStream = new FileInputStream(new File(filePath)); XSSFWorkbook workbook = new XSSFWorkbook(inputStream); XSSFSheet sheet = workbook.getSheetAt(0); StringBuilder sb = new StringBuilder(); for (Row row : sheet) { for (Cell cell : row) { sb.append(cell.toString()).append("\t"); } sb.append("\n"); } tvFileContent.setText(sb.toString()); workbook.close(); inputStream.close(); } catch (IOException e) { e.printStackTrace(); } } ``` 4. 在 Activity 的 onCreate 方法中获取传递过来的文件路径,并调用 readExcelFile 方法: ``` @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_file_viewer); tvFileContent = findViewById(R.id.tv_file_content); String filePath = getIntent().getStringExtra("FILE_PATH"); readExcelFile(filePath); } ``` 这样就可以实现 Android Apache POI 文件浏览功能了。当用户点击一个文件时,可以将文件路径传递给该 Activity,然后在该 Activity 中读取文件内容并显示在 TextView 中。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值