我收到了一个对无效 URL 的非常奇怪的请求:
Invalid URL: /cgi-bin/1st.cgi
Run Code Online (Sandbox Code Playgroud)
这导致以下错误:
SEVERE: Exception initializing page context
java.lang.IllegalStateException: Cannot create a session after the response has been committed
at org.apache.catalina.connector.Request.doGetSession(Request.java:2381)
at org.apache.catalina.connector.Request.getSession(Request.java:2098)
at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)
at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)
at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:544)
...
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
我正在开发我的第一个Windows Phone 7应用程序.我还没有访问实际的设备,所以我依赖SDK附带的模拟器.
在我的应用程序中,我使用EmailComposeTask和SmsComposeTask所需的地方.在模拟器中调试我的应用程序时,我单击一个按钮来运行其中一个任务,它可以工作.但是,当我按下后退按钮退出任务并返回我的应用程序时,应用程序状态丢失了 - 就好像我重新启动它一样.
但是,在它变得奇怪的地方,有时候这种情况不会发生.我不止一次从其中一个任务回来,发现我的应用程序状态确切地说我离开了它.
所以,我的问题:
谢谢.
我正在为我的State Monad实例获得一个<< loop >> Exception,我想这是指一个无限循环,但我看不出我的代码在使用时会如何导致一个:
instance Monad (State' s) where
-- return :: a -> State' s a
return x = State' (\(s,c) -> (x, s, (c <> oneReturn) ))
-- (>>=) :: State' s a -> (a -> State' s b) -> State' s b
st >>= k = State' $ \(s,c) -> let (a, s', c) = runState' st (s,c)
in runState' (k a) (s',(c <> oneBind) )
instance MonadState (State' s) s where
-- get :: State' …Run Code Online (Sandbox Code Playgroud) 我在我的非常基本的 React 应用程序中有一个表单,我想允许用户输入文本并通过更新状态来创建他们的用户名。然而,当点击“确定”按钮时,创建的用户名会在页面上出现大约半秒钟,然后页面会自动刷新并恢复默认状态。只有当按钮包含在表单元素中时才会发生这种情况。它工作正常,当我删除表单元素时页面不会刷新,但是我不想牺牲引导程序表单的样式和格式。这是我的渲染方法:
render() {
return (
<div class="container-fluid text-center">
<form class="form-inline">
<input type="text" class="form-control" placeholder="UserName"/>
<button onClick={this.createUser.bind(this)} class="btn btn-primary">OK</button>
</form>
<h1>User: {this.state.userName}</h1>
<h1>Points: {this.state.points}</h1>
</div>
)
}
Run Code Online (Sandbox Code Playgroud) 我在模态屏幕上有两个文本输入,当我填充第一个输入时 - 状态更新,当我跳到第二个输入并开始输入时 - 第一个输入的值为空.
这是代码:
constructor(){
super()
this.state={
Modal: {
EduModalVisible: false,
ProTitleModalVisible: false,
PsychoModalityModalVisible: false,
},
User: {
NameOfFaculty: '',
YearOfGraduate: '',
}
}
}
Run Code Online (Sandbox Code Playgroud)
文本输入如下所示:
<TextField label={'Faculty'} highlightColor={'#76a6ef'}
value={this.state.User.NameOfFaculty} onChangeText={(faculty) => this.setState({User: { NameOfFaculty: faculty }})} />
<TextField label={'Year Of Graduation'} highlightColor={'#76a6ef'}
value={this.state.User.YearOfGraduate} onChangeText={(year) => this.setState({User: { YearOfGraduate: year }})} />
Run Code Online (Sandbox Code Playgroud)
我认为问题在于更新状态内对象的状态,但我不知道如何解决这个问题.
我有下面的组件,它有4个状态值
class ComposedTextField extends React.Component {
state = {
name: '',
title: '',
email: '',
experience: ''
};
handleChange = event => {
this.setState({
[event.target.name]:event.target.value,
[event.target.title]:event.target.value,
[event.target.email]:event.target.value,
[event.target.experience]:event.target.value
});
};
render() {
const { classes } = this.props;
return (
<div>
<Typography variant="headline">Header Info</Typography>
<FormControl fullWidth className={classes.formControl}>
<InputLabel htmlFor="name-simple">Name</InputLabel>
<Input name="name" value={this.state.name} id="name-simple" onChange={this.handleChange}/>
</FormControl><br></br>
<FormControl fullWidth className={classes.formControl}>
<InputLabel htmlFor="title-simple">Title</InputLabel>
<Input name="title" id="title-simple" value={this.state.title} onChange={this.handleChange}/>
</FormControl><br></br>
<FormControl fullWidth className={classes.formControl}>
<InputLabel htmlFor="email-simple">Email</InputLabel>
<Input name="email" id="email-simple" value={this.state.email} onChange={this.handleChange}/>
</FormControl><br></br>
<FormControl fullWidth className={classes.formControl}> …Run Code Online (Sandbox Code Playgroud) 我有一个带有 Flutter 标签的应用程序,当我通过将设备从纵向旋转到横向来改变方向时,小部件树被重建,小部件的状态被重置。效果是所选选项卡被重置回第一个选项卡。我想防止在方向更改期间重置状态,以便所选选项卡也不会更改。
在我的 State 类中,我使用了 AutomaticKeepAliveClientMixin 并设置了:
@override
bool get wantKeepAlive => true;
Run Code Online (Sandbox Code Playgroud)
但这似乎没有任何效果。
有没有办法确保在旋转设备时保留我的所有应用程序和小部件状态?
如果有帮助,我可以发布代码,尽管我希望这是一个相当通用的问题,但我还没有想到一个简单的答案。
谢谢!
利用 React useReducer 并尝试进行状态更新并在我进行更改时重新渲染。
JSX 调用减速器:
<button onClick={() => dispatch({ type: "DECREMENT", item })} >+</button>
Run Code Online (Sandbox Code Playgroud)
和 useReducer:
const reducer = (state, action) => {
const { item, type } = action;
switch (type) {
case "INCREMENT": {
const newCart = state;
const u = { ...item, quantity: item.quantity + 1 };
const index = newCart.findIndex(eachitem => item.id === eachitem.id);
newCart.splice(index, 1, u);
console.log("INCREMENT", newCart);
return newCart;
}
case "DECREMENT": {
const newCart = state;
const u = { ...item, quantity: …Run Code Online (Sandbox Code Playgroud) 我正在尝试在请求数据方法中为如下所示的字符串变量设置状态
const ViewChangeRequest = () => {
const [requestStageValue, setRequestStage] = useState('');
const { data: requestData, loading: requestDataLoading, error: requestDataError } =
useQuery(GET_SPECIFICREQUEST, {
variables: { requestinputs: { id } },
});
if (requestData != null) {
setRequestStage(requestData.allRequests[0].requestStage.name); // getting error at here
requestData.allRequests.map((code) => {
requestDatasource.push({
id: code.id,
section: code.masterSection.name,
createdBy: code.createdBy,
type: code.requestType.name,
status: code.requestStage.name,
createat: code.createdAt,
});
return null;
});
}
};
export default withRouter(ViewChangeRequest);
Run Code Online (Sandbox Code Playgroud)
取决于 requeststage 值,我正在验证如下条件
if (requestStageValue === 'Request Submitted') {
stepNumber = 0; …Run Code Online (Sandbox Code Playgroud) 我正在为我的游戏应用程序使用 react context api,并创建了一个 GameContext.js
import React, { useState, createContext } from 'react';
const GameContext = createContext();
const GameProvider = ({ children }) => {
const [startgame, setStartgame] = useState(false);
return (
<GameContext.Provider value={[startgame, setStartgame]}>
{children}
</GameContext.Provider>
);
};
export { GameContext, GameProvider };
Run Code Online (Sandbox Code Playgroud)
在 App.js 中,我提供了上下文。
import { GameProvider, GameContext } from './context/GameContext';
const App = () => {
console.log(useContext(GameContext), 'Gamecontext');
return (
<GameProvider>
<div className="App">
{!startgame ? <WelcomeScreen />
: <GameScreen />}
</div>
</GameProvider>
);
};
export default …Run Code Online (Sandbox Code Playgroud) state ×10
reactjs ×6
javascript ×4
cgi-bin ×1
exception ×1
expo ×1
flutter ×1
forms ×1
haskell ×1
html ×1
monads ×1
orientation ×1
react-hooks ×1
react-native ×1
response ×1
session ×1