标签: state

java.lang.IllegalStateException:提交响应后无法创建会话

我收到了一个对无效 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)

我该如何解决这个问题?

session state exception response cgi-bin

0
推荐指数
1
解决办法
3万
查看次数

EmailComposeTask/SmsComposeTask丢失了我的应用状态

我正在开发我的第一个Windows Phone 7应用程序.我还没有访问实际的设备,所以我依赖SDK附带的模拟器.

在我的应用程序中,我使用EmailComposeTaskSmsComposeTask所需的地方.在模拟器中调试我的应用程序时,我单击一个按钮来运行其中一个任务,它可以工作.但是,当我按下后退按钮退出任务并返回我的应用程序时,应用程序状态丢失了 - 就好像我重新启动它一样.

但是,在它变得奇怪的地方,有时候这种情况不会发生.我不止一次从其中一个任务回来,发现我的应用程序状态确切地说我离开了它.

所以,我的问题:

  1. 这只是模拟器的错误吗?
  2. 如果没有,为什么不一致,在调用电子邮件或短信任务之前,我应该如何"保存"我的应用状态?

谢谢.

state windows-phone-7

0
推荐指数
1
解决办法
500
查看次数

Haskell << loop >> Exception

我正在为我的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)

monads state haskell

0
推荐指数
1
解决办法
239
查看次数

无需刷新页面的 ReactJS 引导程序表单

我在我的非常基本的 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)

html javascript forms state reactjs

0
推荐指数
1
解决办法
1838
查看次数

React Native - 状态对象的setState

我在模态屏幕上有两个文本输入,当我填充第一个输入时 - 状态更新,当我跳到第二个输入并开始输入时 - 第一个输入的值为空.

这是代码:

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)

我认为问题在于更新状态内对象的状态,但我不知道如何解决这个问题.

state reactjs react-native expo

0
推荐指数
1
解决办法
4726
查看次数

如何在React js中将状态从一个组件传递到另一个组件?

我有下面的组件,它有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)

javascript state reactjs

0
推荐指数
1
解决办法
6879
查看次数

如何在方向更改时保留 Flutter 中的选定选项卡?

我有一个带有 Flutter 标签的应用程序,当我通过将设备从纵向旋转到横向来改变方向时,小部件树被重建,小部件的状态被重置。效果是所选选项卡被重置回第一个选项卡。我想防止在方向更改期间重置状态,以便所选选项卡也不会更改。

在我的 State 类中,我使用了 AutomaticKeepAliveClientMixin 并设置了:

@override
bool get wantKeepAlive => true;
Run Code Online (Sandbox Code Playgroud)

但这似乎没有任何效果。

有没有办法确保在旋转设备时保留我的所有应用程序和小部件状态?

如果有帮助,我可以发布代码,尽管我希望这是一个相当通用的问题,但我还没有想到一个简单的答案。

谢谢!

state orientation flutter

0
推荐指数
1
解决办法
851
查看次数

使用 useReducer 更新状态时遇到问题

利用 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)

state reactjs

0
推荐指数
1
解决办法
1328
查看次数

收到像 Too many re-renders 这样的错误。React 限制渲染次数以防止无限循环

我正在尝试在请求数据方法中为如下所示的字符串变量设置状态

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)

javascript state reactjs react-hooks

0
推荐指数
1
解决办法
4685
查看次数

如何在同一个组件中提供和使用上下文?

我正在为我的游戏应用程序使用 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)

javascript state reactjs

0
推荐指数
1
解决办法
333
查看次数