Struts 2 与 Apache Shiro 集成时如何显示结果页面
使用: struts2 2.5.10, 春天 4.x, struts2-spring-插件2.5.10, 希罗1.4.0, Shiro-Spring 1.4.0。 网络.xml: 使用: struts2 2.5.10, 春季 4.x, struts2-spring-插件2.5.10, 四郎1.4.0, shiro-spring 1.4.0. web.xml: <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> <display-name>Archetype Created Web Application</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:beans.xml</param-value> </context-param> <filter> <filter-name>shiroFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> <init-param> <param-name>targetFilterLifecycle</param-name> <param-value>true</param-value> </init-param> </filter> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <!-- shiro filter mapping has to be first --> <filter-mapping> <filter-name>shiroFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>INCLUDE</dispatcher> <dispatcher>ERROR</dispatcher> </filter-mapping> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app> beanx.xml: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd "> <bean name="loginAction" class="example.shiro.action.LoginAction" > </bean> <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"> <property name="securityManager" ref="securityManager" /> <property name="loginUrl" value="/login.jsp" /> <property name="filterChainDefinitions"> <value> /login.jsp = authc /logout = logout /* = authc </value> </property> </bean> <bean id="iniRealm" class="org.apache.shiro.realm.text.IniRealm"> <property name="resourcePath" value="classpath:shiro.ini" /> </bean> <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager"> <property name="realm" ref="iniRealm" /> </bean> <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/> </beans> struts.xml: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.devMode" value="true" /> <package name="default" extends="struts-default"> <action name="list" class="loginAction" method="list"> <result name="success">/success.jsp</result> <result name="error">error.jsp</result> </action> </package> </struts> index.jsp: <body> <s:action name="list" /> </body> login.jsp 看起来像: <form name="loginform" action="" method="post"> <table align="left" border="0" cellspacing="0" cellpadding="3"> <tr> <td>Username:</td> <td><input type="text" name="username" maxlength="30"></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="password" maxlength="30"></td> </tr> <tr> <td colspan="2" align="left"><input type="checkbox" name="rememberMe"><font size="2">Remember Me</font></td> </tr> <tr> <td colspan="2" align="right"><input type="submit" name="submit" value="Login"></td> </tr> </table> </form> LoginAction.list(): public String list() { Subject currentUser = SecurityUtils.getSubject(); if(currentUser.isAuthenticated()) {System.out.println("user : "+currentUser.getPrincipal()); System.out.println("You are authenticated!"); } else { System.out.println("Hey hacker, hands up!"); } return "success"; } shiro.ini: [users] root=123,admin guest=456,guest frank=789,roleA,roleB # role name=permission1,permission2,..,permissionN [roles] admin=* roleA=lightsaber:* roleB=winnebago:drive:eagle5 index.jsp、login.jsp、success.jsp放在webapp下 我想要的是:输入LoginAction.list()需要进行身份验证,如果登录成功,则运行LoginAction.list()并返回"success"然后显示定义为Struts操作结果的success.jsp。 现在登录成功后可以执行LoginAction.list(),但是success.jsp不显示,浏览器是空白页面。 为什么? 我找到了原因:我在index.jsp中使用了<s:action name="list" />,但是struts文档说如果我们想用<s:action>看到结果页面,那么我们必须将其属性executeResult设置为true,即就像<s:action name="list" executeResult="true"/>。 在我看来,这有点奇怪,这个属性默认应该是 true。 有一个示例,您应该如何使用 Shiro applicationContext.xml 进行配置: <property name="filterChainDefinitions"> <value> # some example chain definitions: /admin/** = authc, roles[admin] /** = authc # more URL-to-FilterChain definitions here </value> </property> 以 /admin/ 开头的 URL 通过角色 admin 进行保护,任何其他 URL 均不受保护。如果 Struts 操作和结果 JSP 不在受保护区域中,则会显示它们。
PHP8 从函数返回 ZipArchive getStream 使得包含的 zip 存档被关闭
私有函数 getFilePointer($file) { $pathInfo = 路径信息($file); $zip = new ZipArchive(); if (($res = $zip->open($file)) !== true) { 抛出新的例外...
在Win 11 Pro机器上使用Go 1.21.4并为Go绑定GTK 3。 对 Go 中何时/如何调用和使用 init() 函数感到困惑。 简单示例代码: 包 GTKView 进口 ( “github...
在Win 11 Pro机器上使用Go 1.21.4并为Go绑定GTK 3。 对 Go 中何时/如何调用和使用 init() 函数感到困惑。 简单示例代码: 包 GTKView 进口 ( “github...
未捕获错误:未找到“Instamojo\Exception\InstamojoException”类
$authType = "应用程序/用户"; $api = Instamojo\Instamojo::init($authType,[ “client_id”=>“XXXXXQAZ”, “client_secret”=>“XXXXQWE”, ],真的); ...
我正在尝试使用 gcloud init 验证 gcloud sdk。 我得到了一个应该访问的 URL,以便复制令牌并将其返回到 CLI...但我得到的不是令牌,而是以下错误: ...
我正在使用以下文档学习放大器 https://docs.amplify.aws/angular/start/getting-started/installation/ https://docs.amplify.aws/angular/start/getting-started/setup/ 但同时
访问世博会资产的正确方法是什么? 我试过这个: 等待 Asset.loadAsync(require('file:///assets/data/catalog.json')); 错误: 无法解析“file:///assets/data/catalog.json”...
#!/usr/bin/env python3 导入单元测试 从unittest.mock导入补丁 用户类(对象): def __init__(自身): self.__name = 无 self.__authorized_users = ["我", &q...
节点v20.11.1 mjs地址路径错误“不支持“导入ES模块”
,例如,我有一个test.mjs file
我在Nextjs Project中使用Balkan的家谱库。
// edit-form.ts import FamilyTree from "@/plugins/balkan-family-tree/familytree"; import editUI = FamilyTree.editUI; export class EditForm implements editUI { constructor() { } content(id: string | number, detailsMode: boolean, dontAnim: boolean, width: string, dontRenderButtons: boolean): string { return ""; } on(type: "show" | "save" | "cancel" | "element-btn-click" | "button-click" | "hide", listener: (sender: FamilyTree.editUI, args: any, args1: any, args2: any) => (void | boolean)): any { return undefined; } setAvatar(avatarUrl?: string): void { } hide(): void { console.log('hide...'); } init(obj: FamilyTree): void { console.log('init...: ', obj); } show(id: string | number, detailsMode?: boolean, dontAnim?: boolean): void { console.log('show...: ', id, detailsMode, dontAnim); } }
我尝试通过 ruby rbnev 安装 jekyll,然后将 open ~/.bash_profile 放入终端并在文本编辑器中输入 eval "$(rbenv init -bash)" ,这是唯一的方法...
我正在使用以下函数将文件上传到具有角度7的HttpClient的服务器 PushFileToStorage(productId, key, file: File): Observable { 让表单数据:FormData = ...
当我运行 k-means 代码时出现此错误 -> AttributeError: 'NoneType' 对象没有属性 'split'
从 sklearn.cluster 导入 KMeans CS = [] 对于范围 (1, 11) 内的 i: kmeans = KMeans(n_clusters = i, init = 'k-means++', max_iter = 300, n_init = 10, random_state = 0) kmeans.fit(X) cs.
为什么 goGTK 小部件没有在 init() 函数中初始化? [已关闭]
我在 Windows 11 Pro 机器上使用 Go 1.21.4,并使用 GTK 3 绑定 Go。 简单示例代码: 包 GTKView 进口 ( “github.com/gotk3/gotk3/gtk” ) var mToolbar *gtk.Toolbar 变...
如何对使用 package.json 中的 file: 模式安装的本地 NPM 包进行 NPM 重复数据删除对等依赖项?使用 npm 安装软件包时,对等依赖项会正确删除重复数据
`类型“VNode”缺少类型“HTMLElement”中的以下属性:accessKey、accessKeyLabel、autocapitalize、dir 以及其他 283 个属性。 > 导入 { init, classModule, propsModule, styleModule,
编写一个程序,该程序本质上将代码文件复制到数组中,并将缩进保存到数组中以写出到单独的文件中
私有静态 StringTokenizer readFile(String inputFilename) 抛出 FileNotFoundException { 文件 file = new File(inputFilename); 扫描仪扫描仪=新扫描仪(文件); 字符串
我正在尝试优化我的 SwiftUI 应用程序。我有一个奇怪的行为,ViewModel 在其视图中存储为 @StateObject。为了理解这个问题,我做了一个小项目来重现它。 内容视图
安装“ODBC 驱动程序驱动器和 Databricks 集群”
我的集群上的 init 脚本指向 DBFS 路径。错误显示不再支持 DBFS,我必须移动它的工作区或使用 ABFSS 路径。我搬到工作区 pyodbs.sh 看起来像
我正在开发一个使用前端的项目:react native,后端:nodejs 和 mysql,为了接受一些付款,我使用 stripe,但我遇到了很大的问题。在 init 原生反应中...
是否可以在同一属性上使用公共初始化访问器和私有设置器? 目前我收到错误 CS1007“属性访问器已定义”。 公共记录的东西 { 公共...
Android studio,我想用内置方法“Image”发布一个简单的图像。编译器抛出了我在标题中发布的内容。 我正在尝试不同的图像选项和 ImageView 没有
通过更少的 Java API 调用来映射 Google 云端硬盘内容的有效方法
大家好,我有一个代码,用于列出共享驱动器中存在的文件(以便稍后下载并创建相同的文件夹路径) 目前我做这样的事情: 哈希映射 大家好,我有一个代码,用于列出共享驱动器中存在的文件(以便稍后下载并创建相同的文件夹路径) 目前我正在做这样的事情: HashMap<String, Strin> foldersPathToID = new HashMap<>(); //searching all folders first saving their IDs searchAllFoldersRecursive(folderName.trim(), driveId, foldersPathToID); //then listing files in all folders HashMap<String, List<File>> pathFile = new HashMap<>(); for (Entry<String, String> pathFolder : foldersPathToID.entrySet()) { List<File> result = search(Type.FILE, pathFolder.getValue()); if (result.size() > 0) { String targetPathFolder = pathFolder.getKey().trim(); pathFile.putIfAbsent(targetPathFolder, new ArrayList<>()); for (File file : result) { pathFile.get(targetPathFolder).add(file); } } } 递归方法在哪里: private static void searchAllFoldersRecursive(String nameFold, String id, HashMap<String, String> map) throws IOException, RefreshTokenException { map.putIfAbsent(nameFold, id); List<File> result; result = search(Type.FOLDER, id); // dig deeper if (result.size() > 0) { for (File folder : result) { searchAllFoldersRecursive(nameFold + java.io.File.separator + normalizeName(folder.getName()), folder.getId(), map); } } } 搜索功能是: private static List<com.google.api.services.drive.model.File> search(Type type, String folderId) throws IOException, RefreshTokenException { String nextPageToken = "go"; List<File> driveFolders = new ArrayList<>(); com.google.api.services.drive.Drive.Files.List request = service.files() .list() .setQ("'" + folderId + "' in parents and mimeType" + (type == Type.FOLDER ? "=" : "!=") + "'application/vnd.google-apps.folder' and trashed = false") .setPageSize(100).setFields("nextPageToken, files(id, name)"); while (nextPageToken != null && nextPageToken.length() > 0) { try { FileList result = request.execute(); driveFolders.addAll(result.getFiles()); nextPageToken = result.getNextPageToken(); request.setPageToken(nextPageToken); return driveFolders; } catch (TokenResponseException tokenError) { if (tokenError.getDetails().getError().equalsIgnoreCase("invalid_grant")) { log.err("Token no more valid removing it Please retry"); java.io.File cred = new java.io.File("./tokens/StoredCredential"); if (cred.exists()) { cred.delete(); } throw new RefreshTokenException("Creds invalid will retry re allow for the token"); } log.err("Error while geting response with token for folder id : " + folderId, tokenError); nextPageToken = null; } catch (Exception e) { log.err("Error while reading folder id : " + folderId, e); nextPageToken = null; } } return new ArrayList<>(); } 我确信有一种方法可以通过很少的 api 调用(甚至可能是一个调用?)对每个文件(使用文件夹树路径)进行正确的映射,因为在我的版本中,我花了很多时间进行调用 service.files().list().setQ("'" + folderId+ "' in parents and mimeType" + (type == Type.FOLDER ? "=" : "!=") + "'application/vnd.google-apps.folder' and trashed = false").setPageSize(100).setFields("nextPageToken, files(id, name)"); 每个子文件夹至少一次......并且递归搜索所有内容需要很长时间。最后,映射比下载本身花费的时间更多...... 我搜索了文档,也在此处搜索,但没有找到任何内容来列出具有一个库的所有驱动器调用任何想法? 我想使用专用的 java API 来获取共享 GoogleDrive 中的所有文件及其相对路径,但调用次数尽可能少。 提前感谢您的时间和答复 我建议您使用高效的数据结构和逻辑来构建文件夹树并将文件映射到其路径,如下所示 private static void mapDriveContent(String driveId) throws IOException { // HashMap to store folder ID to path mapping HashMap<String, String> idToPath = new HashMap<>(); // HashMap to store files based on their paths HashMap<String, List<File>> pathToFile = new HashMap<>(); // Fetch all files and folders in the drive List<File> allFiles = fetchAllFiles(driveId); // Build folder path mapping and organize files for (File file : allFiles) { String parentId = (file.getParents() != null && !file.getParents().isEmpty()) ? file.getParents().get(0) : null; String path = buildPath(file, parentId, idToPath); if (file.getMimeType().equals("application/vnd.google-apps.folder")) { idToPath.put(file.getId(), path); } else { pathToFile.computeIfAbsent(path, k -> new ArrayList<>()).add(file); } } // Now, pathToFile contains the mapping of paths to files // Your logic to handle these files goes here } private static List<File> fetchAllFiles(String driveId) throws IOException { // Implement fetching all files and folders here // Make sure to handle pagination if necessary // ... } private static String buildPath(File file, String parentId, HashMap<String, String> idToPath) { // Build the file path based on its parent ID and the idToPath mapping // ... }
如何使用cloud-init和Terraform设置主机名?
我从 Terraform 开始。我试图让它设置一个友好的主机名,而不是AWS通常使用的ip-10.10.10.10。但是,我还没有找到如何做到这一点。 我尝试使用配置程序,...
这是我尝试过的: 屏幕 screenWithCalendarField = new Screen(); 比赛日历 = new Match(); 尝试{ 日历 = screenWithCalendarField.find(new File("D:\Sikuli\CalendarField.png").
我目前的尝试是: 文件执行目录 = new File("").getCanonicalFile(); ApplicationInfo信息 = ApplicationRegistry.getApplicationInfoByDir(executionDir); 返回 info.getVersion(); 它...
init方法调用失败; Spring 4 Hibernate 4 项目中的嵌套异常是 java.lang.NullPointerException
我正在尝试使用纯Java配置来设置一个没有XML配置的spring 4 + hibernate 4 Web应用程序。 同时我在启动时遇到以下错误。 13:32:47,649 错误 [org.jb...
我想使用与输入相关的东西来初始化模块中的属性,在第一个 iter 之前,它在 init() 中初始化为零 类模型(nn.Module): def __init__(自身): 超级(模特,自我)。
当我在“sanity init”成功后尝试执行“sanity start”时出现错误
我正在尝试安装 Sanity studio,我按照以下步骤操作: npm install --global @sanity/cli 理智安装 理智初始化 在初始化步骤之后,我尝试运行下一步: 理智开始 但它...
Node v20.10.0 未针对您平台上的 Ember CLI 进行测试
当我尝试启动新的 ember 项目时遇到错误。 我刚刚使用以下命令安装了 ember: npm install -g ember-cli 然后我运行: ember init 来创建我的项目,但它抛出了以下错误...
我按照这个例子来实现角度材料表。 https://stackblitz.com/angular/jejeknenmgr?file=src%2Fapp%2Ftable-basic-example.ts 在这里,我使用...
Flutter 中可以使用什么包来代替 open_file?
我在 Flutter 中有一个项目,我正在使用 open_file 包。我已将 Flutter 生成的 Android apk 上传到 AppSweep,它返回以下问题:Insecure file location is retr...
在store中action的payload中,我使用File类型存储下载的文件,然后该文件将在saga中通过验证 const form = new FormData(); if (私钥 &&
在makefile中的命令前添加反斜杠有什么作用? 例如 本例中的 m 命令: # LaTeX Makefile 文件=报告 全部:$(FILE).pdf .PHONY:干净 干净的: m *.aux...
尝试使用 React Native expo go 从资产文件夹中读取文件 从“expo-asset”导入{资产}; 从“expo-file-system”导入*作为文件系统; ... const getFiles = asy...
如何使用 ag 又名 the_silver_search 仅搜索目录?
我喜欢只搜索目录,选项 ag --list-file-types 对此没有帮助。坚持使用 ag 的原因是可以选择带有 --path-to-ignore 的文件,其中包含 pat...
shortcuts.xml 文件看起来正确。可能是文件位置?我将一个项目复制并粘贴到程序中。我应该导入它吗? 文件位置为 file:///C:/Users/user/Desktop/
使用 kubernetes python 客户端将文件从 pod 复制到主机
我需要使用 kubernetes python 客户端将文件从 pod 复制到主机。它类似于 kubectl cp pod:file file。 我正在测试以下代码:https://github.com/prafull01/Kuberne...
为了提供一些上下文,这是一个 Electron 应用程序,使用 file:// 加载 index.html 内容安全策略似乎正在收缩: 拒绝连接到“https://o944978.ingest.se...
我创建了一个 Stackblitz (https://stackblitz.com/edit/stackblitz-starters-xxbp1t?file=src%2Fmain.ts) 来演示我的多嵌套菜单的问题,但基本问题是当一个用户
我正在写一个简单的引导加载程序, 我正在使用这个 make file 命令将 main.bin 转换为 main_floppy.img cp -f 构建/main.bin 构建/main_floppy.img 但我不断收到此错误 nasm src/...
我正在使用 Stripe,想要实现“卡文件”功能。所以它会是这样的。 用户使用 Stripe Elements 在 UI 上输入信用卡 卡已保存,然后我们每次都会收取费用...
Azure 能否发布管道任务内联 Powershell 连接到 MongoDB load(file) 方法
一直在使用 MDBC powershell 模块连接到 Azure cosmosDB 中的 MongoDB 实例。需要加载带有代码的 .js 文件来更新集合。 示例:(mikesSuperHappyJS.js) var colle...
如何在 Spring boot 的全局异常处理程序中处理 MaxUploadSizeExceededException
我正在我的一项 REST 服务中上传多部分文件数据,并且我使用“spring.servlet.multipart.max-file-size=10MB”属性在 application.properties 中定义了文件大小限制。 ...
使用 Java 8 Stream 在 Writer 对象中写入字符串值
我试图用以下代码中的流替换普通的 for 循环,该循环在 Writer 对象中写入字符串值: 公共无效保存(){ 尝试 (Writer fileWriter = new FileWriter(file)) {...
Tinylog 中的滚动文件会覆盖每次应用程序启动时的日志文件
我在Kotlin 2.6.2版本中使用tinylog。 这是我的tinylog.properties 文件: writer2 = 滚动文件 writer2.level = 信息 writer2.file = #{tinylog.directory}/log_{日期:yyyy-MM-dd}.{动态:
我正在使用 Isabelle 来验证 C 程序。在验证过程中,我使用c-parser install-C-file加载代码,但是出现了以下问题: 尝试导致指针衰减
Laravel9 response()->stream() 使用 fwrite() 得到空结果
我需要将大量数据导出为 CSV 字符串。 所以我尝试将 fopen('php://stdout', w) 与 fwrite($file, $data) 一起使用。 但 Laravel response()->stream() 不会返回任何内容,也不会出现错误。 我...
本地主机上的我的 Parcel React 网站在使用 chrome 检查选项卡打开时需要 10 秒时间,并且在未打开检查选项卡时快速加载
我正在从akshay saini的合十礼反应课程中学习反应。 我创建了 2 个文件。 索引.html 脚本.js 然后我启动了npm init。 之后我向其中添加了包裹,然后运行 npx 包裹索引.h...